Skip to content

Commit a56d4dc

Browse files
author
Artūrs Jānis Pētersons
committed
Check PCKE only for Authorization code flow
1 parent f3419dd commit a56d4dc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

server/server.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,6 @@ func (s *Server) ValidationTokenRequest(r *http.Request) (oauth2.GrantType, *oau
311311
return "", nil, errors.ErrUnsupportedGrantType
312312
}
313313

314-
codeVer := r.FormValue("code_verifier")
315-
if s.Config.ForcePKCE && codeVer == "" {
316-
return "", nil, errors.ErrInvalidRequest
317-
}
318-
319314
clientID, clientSecret, err := s.ClientInfoHandler(r)
320315
if err != nil {
321316
return "", nil, err
@@ -335,7 +330,10 @@ func (s *Server) ValidationTokenRequest(r *http.Request) (oauth2.GrantType, *oau
335330
tgr.Code == "" {
336331
return "", nil, errors.ErrInvalidRequest
337332
}
338-
tgr.CodeVerifier = codeVer
333+
tgr.CodeVerifier = r.FormValue("code_verifier")
334+
if s.Config.ForcePKCE && tgr.CodeVerifier == "" {
335+
return "", nil, errors.ErrInvalidRequest
336+
}
339337
case oauth2.PasswordCredentials:
340338
tgr.Scope = r.FormValue("scope")
341339
username, password := r.FormValue("username"), r.FormValue("password")

0 commit comments

Comments
 (0)