git.iko.soy/typeable/oauth2-proxy
on master help sign in
No need for case when only 2 conditions
commitd69560d0200e778bfc1a5db372f4a27f6947f4fb authorAdam Eijdenberg <adam.eijdenberg@digital.gov.au> dateSat 15 Jun 2019, 18:48 (7 years ago) parentf35c82b
2 files changed+7−6
CHANGELOG.md+1 oauthproxy.go+6−6
CHANGELOG.md+1
@@ -14,6 +14,7 @@
1414
1515## Changes since v3.2.0
1616
17+- [#180](https://github.com/pusher/outh2_proxy/pull/180) Minor refactor of core proxying path (@aeijdenberg).
1718- [#175](https://github.com/pusher/outh2_proxy/pull/175) Bump go-oidc to v2.0.0 (@aeijdenberg).
1819 - Includes fix for potential signature checking issue when OIDC discovery is skipped.
1920- [#155](https://github.com/pusher/outh2_proxy/pull/155) Add RedisSessionStore implementation (@brianv0, @JoelSpeed)
oauthproxy.go+6−6
@@ -646,14 +646,14 @@ func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
646646// AuthenticateOnly checks whether the user is currently logged in
647647func (p *OAuthProxy) AuthenticateOnly(rw http.ResponseWriter, req *http.Request) {
648648 session, err := p.getAuthenticatedSession(rw, req)
649− switch err {
650− case nil:
651− // we are authenticated
652− p.addHeadersForProxying(rw, req, session)
653− rw.WriteHeader(http.StatusAccepted)
654− default:
649+ if err != nil {
655650 http.Error(rw, "unauthorized request", http.StatusUnauthorized)
651+ return
656652 }
653+
654+ // we are authenticated
655+ p.addHeadersForProxying(rw, req, session)
656+ rw.WriteHeader(http.StatusAccepted)
657657}
658658
659659// Proxy proxies the user request if the user is authenticated else it prompts