Skip to content

Commit

Permalink
oauth2: Share error details with redirect fallback (#982)
Browse files Browse the repository at this point in the history
Closes #974

Signed-off-by: arekkas <aeneas@ory.am>
  • Loading branch information
arekkas authored Aug 8, 2018
1 parent 0b722b9 commit 123e37e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/server/handler_oauth2_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func newOAuth2Handler(c *config.Config, frontend, backend *httprouter.Router, cm
AccessTokenJWTStrategy: accessTokenJWTStrategy,
AccessTokenStrategy: c.OAuth2AccessTokenStrategy,
IDTokenLifespan: c.GetIDTokenLifespan(),
ShareOAuth2Debug: c.SendOAuth2DebugMessagesToClients,
}

handler.SetRoutes(frontend, backend)
Expand Down
7 changes: 6 additions & 1 deletion oauth2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,13 @@ func (h *Handler) writeAuthorizeError(w http.ResponseWriter, ar fosite.Authorize
query := redirectURI.Query()
query.Add("error", rfcerr.Name)
query.Add("error_description", rfcerr.Description)
redirectURI.RawQuery = query.Encode()
query.Add("error_hint", rfcerr.Hint)

if h.ShareOAuth2Debug {
query.Add("error_debug", rfcerr.Debug)
}

redirectURI.RawQuery = query.Encode()
w.Header().Add("Location", redirectURI.String())
w.WriteHeader(http.StatusFound)
return
Expand Down
2 changes: 2 additions & 0 deletions oauth2/handler_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ type Handler struct {
ClaimsSupported string
ScopesSupported string
UserinfoEndpoint string

ShareOAuth2Debug bool
}

0 comments on commit 123e37e

Please sign in to comment.