-
Notifications
You must be signed in to change notification settings - Fork 16
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
IAM: Implement correct OAuth2 error handling #2515
Conversation
redirectURI, _ := url.Parse(oauthErr.RedirectURI) | ||
if oauthErr.RedirectURI == "" || redirectURI == nil { | ||
// Can't redirect the user-agent back, render error as JSON or plain text (depending on content-type) | ||
contentType := echoContext.Request().Header.Get("Content-Type") |
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.
Content-Type
or Accept
header?
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.
At first, I had both. But that introduced unused code paths (Accept
header being application/json
), which adds complexity and no value. So given the assumption that a browser will never send application/json
as content-type (maybe with a form post with enctype set to that value, but that would be very, very weird?), and API clients will use JSON, I just settles on Content-Type = application/json
for now.
When proven otherwise in future, we can easily adapt this.
9d0b24e
to
f5c6a30
Compare
Force-pushed after fixing conflicts a bit too early |
Suggestion applied. |
This PR introduces an OAuth2 error handler that:
redirect_uri
(witherror
anderror_description
parameters)redirect_uri
, it either prints the error as plain text (for a browser) or JSON (for an API client)It also fixes HTTP request logging status codes for the IAM API package.