git.iko.soy/typeable/oauth2-proxy
on master help sign in
Make ProcessCookie() fail when cookie parse fails
commit610341a068999e89a53dfdab16c33e41d3b4bf76 authorMike Bland <michael.bland@gsa.gov> dateSat 9 May 2015, 16:31 (11 years ago) parentbd4eae8
2 files changed+12
oauthproxy.go+1 oauthproxy_test.go+11
oauthproxy.go+1
@@ -298,6 +298,7 @@ func (p *OauthProxy) ProcessCookie(rw http.ResponseWriter, req *http.Request) (e
298298 }
299299 if err != nil {
300300 log.Printf(err.Error())
301+ ok = false
301302 } else if p.CookieRefresh != time.Duration(0) {
302303 refresh_threshold := time.Now().Add(p.CookieRefresh)
303304 if refresh_threshold.Unix() > timestamp.Unix() {
oauthproxy_test.go+11
@@ -474,6 +474,17 @@ func TestProcessCookieNoCookieError(t *testing.T) {
474474 assert.Equal(t, false, ok)
475475}
476476
477+func TestProcessCookieFailIfParsingCookieValueFails(t *testing.T) {
478+ pc_test := NewProcessCookieTest()
479+ value, _ := buildCookieValue("michael.bland@gsa.gov",
480+ pc_test.proxy.AesCipher, "my_access_token")
481+ pc_test.req.AddCookie(pc_test.proxy.MakeCookie(
482+ pc_test.req, value+"some bogus bytes",
483+ pc_test.opts.CookieExpire))
484+ _, _, _, ok := pc_test.ProcessCookie()
485+ assert.Equal(t, false, ok)
486+}
487+
477488func TestProcessCookieRefreshNotSet(t *testing.T) {
478489 pc_test := NewProcessCookieTest()
479490 pc_test.InstantiateBackend()