From fb54f541f990f4d61f6ec4d4480625e1d60ce8e9 Mon Sep 17 00:00:00 2001 From: ras0q Date: Tue, 7 Feb 2023 15:09:10 +0900 Subject: [PATCH] :fire: quit saving code_challenge --- example/webapp/main.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/example/webapp/main.go b/example/webapp/main.go index a11e0f3..f0e25ef 100644 --- a/example/webapp/main.go +++ b/example/webapp/main.go @@ -45,6 +45,14 @@ func authorizeHandler(w http.ResponseWriter, r *http.Request) { return } + session, err := globalManager.RetrieveSession(w, r) + if err != nil { + handleInternalServerError(w, err) + return + } + + session.Set(codeVerifierKey, codeVerifier) + codeChallengeMethod := traqoauth2.CodeChallengeMethod(r.URL.Query().Get("method")) if codeChallengeMethod == "" { codeChallengeMethod = traqoauth2.CodeChallengePlain @@ -56,16 +64,6 @@ func authorizeHandler(w http.ResponseWriter, r *http.Request) { return } - session, err := globalManager.RetrieveSession(w, r) - if err != nil { - handleInternalServerError(w, err) - return - } - - session.Set(codeVerifierKey, codeVerifier) - session.Set(codeChallengeKey, codeChallenge) - session.Set(codeChallengeMethodKey, codeChallengeMethod) - authCodeURL := conf.AuthCodeURL( r.URL.Query().Get("state"), traqoauth2.WithCodeChallenge(codeChallenge), @@ -173,8 +171,6 @@ const ( sessionName string = "traq-oauth2-example" codeVerifierKey sessionKey = "code_verifier" - codeChallengeKey sessionKey = "code_challenge" - codeChallengeMethodKey sessionKey = "code_challenge_method" userKey sessionKey = "user" )