Skip to content

Commit

Permalink
Improve error descriptions for unauthorized_client, distinguishing di…
Browse files Browse the repository at this point in the history
…fferent causes
  • Loading branch information
hickford committed Sep 28, 2022
1 parent 677a09e commit 9f4a10e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions routers/web/auth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func handleRefreshToken(ctx *context.Context, form forms.AccessTokenForm, server
if err != nil {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
ErrorDescription: "client is not authorized",
ErrorDescription: "unable to parse refresh token",
})
return
}
Expand Down Expand Up @@ -688,14 +688,14 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
if !app.ValidateClientSecret([]byte(form.ClientSecret)) {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
ErrorDescription: "client is not authorized",
ErrorDescription: "invalid client secret",
})
return
}
if form.RedirectURI != "" && !app.ContainsRedirectURI(form.RedirectURI) {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
ErrorDescription: "client is not authorized",
ErrorDescription: "unexpected redirect URI",
})
return
}
Expand All @@ -711,7 +711,7 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
if !authorizationCode.ValidateCodeChallenge(form.CodeVerifier) {
handleAccessTokenError(ctx, AccessTokenError{
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
ErrorDescription: "client is not authorized",
ErrorDescription: "failed PKCE code challenge",
})
return
}
Expand Down

0 comments on commit 9f4a10e

Please sign in to comment.