Remove unneeded cookie fields from OAuth2 Proxy
This commit is contained in:
		
							parent
							
								
									812aabe5da
								
							
						
					
					
						commit
						f819200325
					
				|  | @ -66,7 +66,7 @@ type allowedRoute struct { | ||||||
| 
 | 
 | ||||||
| // OAuthProxy is the main authentication proxy
 | // OAuthProxy is the main authentication proxy
 | ||||||
| type OAuthProxy struct { | type OAuthProxy struct { | ||||||
| 	CookieOptions *options.Cookie | 	CookieSecure bool | ||||||
| 	Validator    func(string) bool | 	Validator    func(string) bool | ||||||
| 
 | 
 | ||||||
| 	SignInPath string | 	SignInPath string | ||||||
|  | @ -191,7 +191,7 @@ func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthPr | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	p := &OAuthProxy{ | 	p := &OAuthProxy{ | ||||||
| 		CookieOptions: &opts.Cookie, | 		CookieSecure: opts.Cookie.Secure, | ||||||
| 		Validator:    validator, | 		Validator:    validator, | ||||||
| 
 | 
 | ||||||
| 		SignInPath: fmt.Sprintf("%s/sign_in", opts.ProxyPrefix), | 		SignInPath: fmt.Sprintf("%s/sign_in", opts.ProxyPrefix), | ||||||
|  |  | ||||||
|  | @ -434,7 +434,7 @@ func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int, cookie | ||||||
| // getEndpointWithCookie makes a requests againt the oauthproxy with passed requestPath
 | // getEndpointWithCookie makes a requests againt the oauthproxy with passed requestPath
 | ||||||
| // and cookie and returns body and status code.
 | // and cookie and returns body and status code.
 | ||||||
| func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoint string) (httpCode int, accessToken string) { | func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoint string) (httpCode int, accessToken string) { | ||||||
| 	cookieName := patTest.proxy.CookieOptions.Name | 	cookieName := patTest.opts.Cookie.Name | ||||||
| 	var value string | 	var value string | ||||||
| 	keyPrefix := cookieName + "=" | 	keyPrefix := cookieName + "=" | ||||||
| 
 | 
 | ||||||
|  | @ -750,9 +750,6 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts, modifiers ...OptionsModifi | ||||||
| 	} | 	} | ||||||
| 	pcTest.proxy.provider.(*TestProvider).SetAllowedGroups(pcTest.opts.Providers[0].AllowedGroups) | 	pcTest.proxy.provider.(*TestProvider).SetAllowedGroups(pcTest.opts.Providers[0].AllowedGroups) | ||||||
| 
 | 
 | ||||||
| 	// Now, zero-out proxy.CookieRefresh for the cases that don't involve
 |  | ||||||
| 	// access_token validation.
 |  | ||||||
| 	pcTest.proxy.CookieOptions.Refresh = time.Duration(0) |  | ||||||
| 	pcTest.rw = httptest.NewRecorder() | 	pcTest.rw = httptest.NewRecorder() | ||||||
| 	pcTest.req, _ = http.NewRequest("GET", "/", strings.NewReader("")) | 	pcTest.req, _ = http.NewRequest("GET", "/", strings.NewReader("")) | ||||||
| 	pcTest.validateUser = true | 	pcTest.validateUser = true | ||||||
|  | @ -874,7 +871,6 @@ func TestProcessCookieFailIfRefreshSetAndCookieExpired(t *testing.T) { | ||||||
| 	err = pcTest.SaveSession(startSession) | 	err = pcTest.SaveSession(startSession) | ||||||
| 	assert.NoError(t, err) | 	assert.NoError(t, err) | ||||||
| 
 | 
 | ||||||
| 	pcTest.proxy.CookieOptions.Refresh = time.Hour |  | ||||||
| 	session, err := pcTest.LoadCookiedSession() | 	session, err := pcTest.LoadCookiedSession() | ||||||
| 	assert.NotEqual(t, nil, err) | 	assert.NotEqual(t, nil, err) | ||||||
| 	if session != nil { | 	if session != nil { | ||||||
|  | @ -1624,7 +1620,7 @@ func TestClearSplitCookie(t *testing.T) { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	p := OAuthProxy{CookieOptions: &opts.Cookie, sessionStore: store} | 	p := OAuthProxy{sessionStore: store} | ||||||
| 	var rw = httptest.NewRecorder() | 	var rw = httptest.NewRecorder() | ||||||
| 	req := httptest.NewRequest("get", "/", nil) | 	req := httptest.NewRequest("get", "/", nil) | ||||||
| 
 | 
 | ||||||
|  | @ -1657,7 +1653,7 @@ func TestClearSingleCookie(t *testing.T) { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	p := OAuthProxy{CookieOptions: &opts.Cookie, sessionStore: store} | 	p := OAuthProxy{sessionStore: store} | ||||||
| 	var rw = httptest.NewRecorder() | 	var rw = httptest.NewRecorder() | ||||||
| 	req := httptest.NewRequest("get", "/", nil) | 	req := httptest.NewRequest("get", "/", nil) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue