Skip to content

Commit

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

Signed-off-by: arekkas <aeneas@ory.am>
  • Loading branch information
arekkas committed Aug 7, 2018
1 parent ce4e4ef commit f4b928a
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
Expand Up @@ -195,6 +195,7 @@ func newOAuth2Handler(c *config.Config, frontend, backend *httprouter.Router, cm
OpenIDJWTStrategy: openIDJWTStrategy,
AccessTokenJWTStrategy: accessTokenJWTStrategy,
IDTokenLifespan: c.GetIDTokenLifespan(),
ShareOAuth2Debug: c.SendOAuth2DebugMessagesToClients,
}

handler.SetRoutes(frontend, backend)
Expand Down
7 changes: 6 additions & 1 deletion oauth2/handler.go
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
Expand Up @@ -59,4 +59,6 @@ type Handler struct {
ClaimsSupported string
ScopesSupported string
UserinfoEndpoint string

ShareOAuth2Debug bool
}

0 comments on commit f4b928a

Please sign in to comment.