Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
🔥 quit saving code_challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0q committed Feb 7, 2023
1 parent 5e2415d commit fb54f54
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions example/webapp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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"
)

Expand Down

0 comments on commit fb54f54

Please sign in to comment.