-
Notifications
You must be signed in to change notification settings - Fork 12
AB-705 mandatory code_verifier for public client #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,36 +162,53 @@ func (s *Server) HandleAccessRequest(w *Response, r *http.Request) *AccessReques | |
| } | ||
|
|
||
| func (s *Server) handleAuthorizationCodeRequest(w *Response, r *http.Request) *AccessRequest { | ||
| auth, err := CheckBasicAuth(r) | ||
| clientID := r.Form.Get("client_id") | ||
| if clientID == "" { | ||
| w.SetError(E_UNAUTHORIZED_CLIENT, "") | ||
| return nil | ||
| } | ||
| client, err := w.Storage.GetClient(clientID) | ||
| if err != nil { | ||
| w.SetError(E_SERVER_ERROR, "") | ||
| w.InternalError = err | ||
| return nil | ||
| } | ||
| if client == nil { | ||
| w.SetError(E_UNAUTHORIZED_CLIENT, "") | ||
| return nil | ||
| } | ||
| var publicClient bool | ||
| if CheckClientSecret(client, ""){ | ||
| publicClient=true | ||
|
|
||
| var clientID string | ||
| var client Client | ||
| if auth == nil { | ||
| clientID = r.Form.Get("client_id") | ||
| if clientID == "" { | ||
| w.SetError(E_UNAUTHORIZED_CLIENT, "") | ||
| return nil | ||
| } | ||
| client = getClientWithoutSecret(clientID, w.Storage, w) | ||
| } else { | ||
| } else{ | ||
| // get client authentication | ||
| auth := GetClientAuth(w, r, s.Config.AllowClientSecretInParams) | ||
| if auth == nil { | ||
| return nil | ||
| } | ||
| client = getClient(auth, w.Storage, w) | ||
| if !CheckClientSecret(client,auth.Password){ | ||
| w.SetError(E_UNAUTHORIZED_CLIENT, "") | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
|
|
||
| var codeVerifier string | ||
| // Optional PKCE support (https://tools.ietf.org/html/rfc7636) | ||
| if codeVerifier = r.Form.Get("code_verifier"); len(codeVerifier) == 0 { | ||
| if s.Config.RequirePKCEForPublicClients && publicClient { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will not check the PKCE challenge / verifier if it's not enabled |
||
| // https://tools.ietf.org/html/rfc7636#section-4.4.1 | ||
| w.SetError(E_INVALID_REQUEST, "code_verifier (rfc7636) required for public clients") | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| // generate access token | ||
| ret := &AccessRequest{ | ||
| Type: AUTHORIZATION_CODE, | ||
| Code: r.Form.Get("code"), | ||
| CodeVerifier: r.Form.Get("code_verifier"), | ||
| CodeVerifier: codeVerifier, | ||
| RedirectUri: r.Form.Get("redirect_uri"), | ||
| GenerateRefresh: true, | ||
| Expiration: s.Config.AccessExpiration, | ||
|
|
@@ -250,7 +267,7 @@ func (s *Server) handleAuthorizationCodeRequest(w *Response, r *http.Request) *A | |
| } | ||
| if ret.AuthorizeData.RedirectUri != ret.RedirectUri { | ||
| w.SetError(E_INVALID_REQUEST, "") | ||
| w.InternalError = errors.New("Redirect uri is different") | ||
| w.InternalError = errors.New("redirect uri is different") | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please help me to review @anggorodewanto @thoriqsatriya @banukusuma @rjjatson @desniaak