1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-05-27 23:08:10 +02:00

Remove unneeded cookie fields from OAuth2 Proxy

This commit is contained in:
Joel Speed 2021-03-23 18:15:10 +00:00 committed by Joel Speed
parent 812aabe5da
commit f819200325
No known key found for this signature in database
GPG Key ID: 6E80578D6751DEFB
2 changed files with 7 additions and 11 deletions

View File

@ -66,7 +66,7 @@ type allowedRoute struct {
// OAuthProxy is the main authentication proxy
type OAuthProxy struct {
CookieOptions *options.Cookie
CookieSecure bool
Validator func(string) bool
SignInPath string
@ -191,7 +191,7 @@ func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthPr
})
p := &OAuthProxy{
CookieOptions: &opts.Cookie,
CookieSecure: opts.Cookie.Secure,
Validator: validator,
SignInPath: fmt.Sprintf("%s/sign_in", opts.ProxyPrefix),

View File

@ -434,7 +434,7 @@ func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int, cookie
// getEndpointWithCookie makes a requests againt the oauthproxy with passed requestPath
// and cookie and returns body and status code.
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
keyPrefix := cookieName + "="
@ -750,9 +750,6 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts, modifiers ...OptionsModifi
}
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.req, _ = http.NewRequest("GET", "/", strings.NewReader(""))
pcTest.validateUser = true
@ -874,7 +871,6 @@ func TestProcessCookieFailIfRefreshSetAndCookieExpired(t *testing.T) {
err = pcTest.SaveSession(startSession)
assert.NoError(t, err)
pcTest.proxy.CookieOptions.Refresh = time.Hour
session, err := pcTest.LoadCookiedSession()
assert.NotEqual(t, nil, err)
if session != nil {
@ -1624,7 +1620,7 @@ func TestClearSplitCookie(t *testing.T) {
t.Fatal(err)
}
p := OAuthProxy{CookieOptions: &opts.Cookie, sessionStore: store}
p := OAuthProxy{sessionStore: store}
var rw = httptest.NewRecorder()
req := httptest.NewRequest("get", "/", nil)
@ -1657,7 +1653,7 @@ func TestClearSingleCookie(t *testing.T) {
t.Fatal(err)
}
p := OAuthProxy{CookieOptions: &opts.Cookie, sessionStore: store}
p := OAuthProxy{sessionStore: store}
var rw = httptest.NewRecorder()
req := httptest.NewRequest("get", "/", nil)