Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
instead of ctx.error use ctx.json so that clients
parse error and error_description correctly
  • Loading branch information
Nils Hillmann committed May 5, 2021
commit d25562814d4a92e4f0373f409f0085e0f5bf6bd5
10 changes: 5 additions & 5 deletions routers/user/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ const (

// BearerTokenError represents an error response specified in RFC 6750
type BearerTokenError struct {
ErrorCode BearerTokenErrorCode
ErrorDescription string
ErrorCode BearerTokenErrorCode `json:"error" form:"error"`
ErrorDescription string `json:"error_description"`
}

// TokenType specifies the kind of token
Expand Down Expand Up @@ -635,12 +635,12 @@ func handleAuthorizeError(ctx *context.Context, authErr AuthorizeError, redirect
func handleBearerTokenError(ctx *context.Context, beErr BearerTokenError) {
ctx.Resp.Header().Set("WWW-Authenticate", fmt.Sprintf("Bearer realm=\"\", error=\"%s\", error_description=\"%s\"", beErr.ErrorCode, beErr.ErrorDescription))
if beErr.ErrorCode == BearerTokenErrorCodeInvalidRequest {
ctx.Error(http.StatusBadRequest)
ctx.JSON(http.StatusBadRequest, beErr)
}
if beErr.ErrorCode == BearerTokenErrorCodeInvalidToken {
ctx.Error(http.StatusUnauthorized)
ctx.JSON(http.StatusUnauthorized, beErr)
}
if beErr.ErrorCode == BearerTokenErrorCodeInsufficientScope {
ctx.Error(http.StatusForbidden)
ctx.JSON(http.StatusForbidden, beErr)
}
}