From fe7edeefca3cc8b7a75e8df76b6248b3daac27b6 Mon Sep 17 00:00:00 2001 From: Pavol Ipoth Date: Thu, 12 Nov 2020 16:53:35 +0100 Subject: [PATCH] Verify id token not access token --- handlers.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/handlers.go b/handlers.go index 87b55b73..b8dfb948 100644 --- a/handlers.go +++ b/handlers.go @@ -139,6 +139,13 @@ func (r *oauthProxy) oauthCallbackHandler(w http.ResponseWriter, req *http.Reque return } + // step: check the id token is valid + if err = verifyToken(r.client, token); err != nil { + r.log.Error("unable to verify the id token", zap.Error(err)) + r.accessForbidden(w, req) + return + } + access, id, err := parseToken(resp.AccessToken) if err == nil { token = access @@ -146,13 +153,6 @@ func (r *oauthProxy) oauthCallbackHandler(w http.ResponseWriter, req *http.Reque } else { r.log.Warn("unable to parse the access token, using id token only", zap.Error(err)) } - - // step: check the access token is valid - if err = verifyToken(r.client, token); err != nil { - r.log.Error("unable to verify the id token", zap.Error(err)) - r.accessForbidden(w, req) - return - } accessToken := token.Encode() // step: are we encrypting the access token?