git.iko.soy/typeable/oauth2-proxy
on master help sign in
Remove unused fields from OAuthProxy
commitc0654e3d9f6cb6d888bc2b71a2c2c429e9ac4bea authorJoel Speed <joel.speed@hotmail.co.uk> dateWed 24 Mar 2021, 22:30 (6 years ago) parent8c25f5b
3 files changed+4−22
CHANGELOG.md+1 oauthproxy.go−15 oauthproxy_test.go+3−7
CHANGELOG.md+1
@@ -9,6 +9,7 @@
99## Changes since v7.1.1
1010
1111- [#1129](https://github.com/oauth2-proxy/oauth2-proxy/pull/1129) Rewrite OpenRedirect tests in ginkgo (@JoelSpeed)
12+- [#1127](https://github.com/oauth2-proxy/oauth2-proxy/pull/1127) Remove unused fields from OAuthProxy (@JoelSpeed)
1213
1314# V7.1.1
1415
oauthproxy.go−15
@@ -60,15 +60,12 @@ type allowedRoute struct {
6060
6161// OAuthProxy is the main authentication proxy
6262type OAuthProxy struct {
63− CookieSeed string
64− CookieName string
6563 CSRFCookieName string
6664 CookieDomains []string
6765 CookiePath string
6866 CookieSecure bool
6967 CookieHTTPOnly bool
7068 CookieExpire time.Duration
71− CookieRefresh time.Duration
7269 CookieSameSite string
7370 Validator func(string) bool
7471
@@ -88,16 +85,7 @@ type OAuthProxy struct {
8885 ProxyPrefix string
8986 basicAuthValidator basic.Validator
9087 serveMux http.Handler
91− SetXAuthRequest bool
92− PassBasicAuth bool
93− SetBasicAuth bool
9488 SkipProviderButton bool
95− PassUserHeaders bool
96− BasicAuthPassword string
97− PassAccessToken bool
98− SetAuthorization bool
99− PassAuthorization bool
100− PreferEmailToUser bool
10189 skipAuthPreflight bool
10290 skipJwtBearerTokens bool
10391 realClientIPParser ipapi.RealClientIPParser
@@ -191,15 +179,12 @@ func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthPr
191179 }
192180
193181 p := &OAuthProxy{
194− CookieName: opts.Cookie.Name,
195182 CSRFCookieName: fmt.Sprintf("%v_%v", opts.Cookie.Name, "csrf"),
196− CookieSeed: opts.Cookie.Secret,
197183 CookieDomains: opts.Cookie.Domains,
198184 CookiePath: opts.Cookie.Path,
199185 CookieSecure: opts.Cookie.Secure,
200186 CookieHTTPOnly: opts.Cookie.HTTPOnly,
201187 CookieExpire: opts.Cookie.Expire,
202− CookieRefresh: opts.Cookie.Refresh,
203188 CookieSameSite: opts.Cookie.SameSite,
204189 Validator: validator,
205190
oauthproxy_test.go+3−7
@@ -714,7 +714,7 @@ func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int,
714714// getEndpointWithCookie makes a requests againt the oauthproxy with passed requestPath
715715// and cookie and returns body and status code.
716716func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoint string) (httpCode int, accessToken string) {
717− cookieName := patTest.proxy.CookieName
717+ cookieName := patTest.opts.Cookie.Name
718718 var value string
719719 keyPrefix := cookieName + "="
720720
@@ -983,9 +983,6 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts, modifiers ...OptionsModifi
983983 }
984984 pcTest.proxy.provider.(*TestProvider).SetAllowedGroups(pcTest.opts.AllowedGroups)
985985
986− // Now, zero-out proxy.CookieRefresh for the cases that don't involve
987− // access_token validation.
988− pcTest.proxy.CookieRefresh = time.Duration(0)
989986 pcTest.rw = httptest.NewRecorder()
990987 pcTest.req, _ = http.NewRequest("GET", "/", strings.NewReader(""))
991988 pcTest.validateUser = true
@@ -1107,7 +1104,6 @@ func TestProcessCookieFailIfRefreshSetAndCookieExpired(t *testing.T) {
11071104 err = pcTest.SaveSession(startSession)
11081105 assert.NoError(t, err)
11091106
1110− pcTest.proxy.CookieRefresh = time.Hour
11111107 session, err := pcTest.LoadCookiedSession()
11121108 assert.NotEqual(t, nil, err)
11131109 if session != nil {
@@ -2003,7 +1999,7 @@ func TestClearSplitCookie(t *testing.T) {
20031999 t.Fatal(err)
20042000 }
20052001
2006− p := OAuthProxy{CookieName: opts.Cookie.Name, CookieDomains: opts.Cookie.Domains, sessionStore: store}
2002+ p := OAuthProxy{sessionStore: store}
20072003 var rw = httptest.NewRecorder()
20082004 req := httptest.NewRequest("get", "/", nil)
20092005
@@ -2036,7 +2032,7 @@ func TestClearSingleCookie(t *testing.T) {
20362032 t.Fatal(err)
20372033 }
20382034
2039− p := OAuthProxy{CookieName: opts.Cookie.Name, CookieDomains: opts.Cookie.Domains, sessionStore: store}
2035+ p := OAuthProxy{sessionStore: store}
20402036 var rw = httptest.NewRecorder()
20412037 req := httptest.NewRequest("get", "/", nil)
20422038