-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix: show OAuth2 error details on error screen #277
Conversation
src/routes/error.ts
Outdated
} | ||
|
||
function isOAuth2Error(query: qs.ParsedQs): query is OAuth2Error { | ||
return query.error !== undefined && query.error_description !== undefined |
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.
Can there be other parameters, as well? Is there a case where one of these wouldn't be present?
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.
unsure, might need to refer to hydra docs
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.
I don't know if we always have error_description
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.
https://github.com/ory/fosite/blob/master/errors.go#L460
error_hint
is super useful
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.
Nice, I removed the error_description
requirement and added an option error_hint
. We'll need to observe if anything else should be in there.
src/routes/error.ts
Outdated
} | ||
|
||
function isOAuth2Error(query: qs.ParsedQs): query is OAuth2Error { | ||
return query.error !== undefined && query.error_description !== undefined |
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.
unsure, might need to refer to hydra docs
src/routes/error.ts
Outdated
}), | ||
}) | ||
} catch (err) { | ||
// The error could not be found or there was an error fetching it, redirect back to home. | ||
res.redirect("welcome") |
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.
what happens if the welcome page is disabled? Could we not have a redirect back to req.header("Referer")
instead here?
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.
Wouldn't that be the flow that the error occurred in? Might lead to infinite redirects, right?
But I agree that we need more sophisticated handling here. But now sure where to...
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.
hmm, true. Maybe to the project error page? I wonder if we could get these URLs from the backoffice somehow.
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.
Maybe to the project error page
Isn't this the project error page?
I wonder if we could get these URLs from the backoffice somehow.
Also a possibility.
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.
Show an error that describes what happened and what the user can do
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.
Show an error that describes what happened and what the user can do
Lol, yeah, sometimes the best solution is the most intuitive. Didn't even think of that. I added some handling around that.
@Benehiko would be great to increase the width of the error box, as the JSON can get quite long. Would that be easy to do within elements? |
Yes, can be done in elements |
Can also override the styling for this in hostedui if you want. I think you should be able to |
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.
I think it looks fine, just wondering about the status code 599 your'e returning from the OAuth error
...(query.error_hint | ||
? { hint: decodeURIComponent(query.error_hint.toString()) } | ||
: {}), | ||
code: 599, // Dummy code to trigger the full error screen |
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.
why do we need a dummy code? why not just make it 400?
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.
to trigger the full error screen
Otherwise, we only show the message
, bot the id
, etc.
https://github.com/ory/elements/blob/main/src/react-components/ory/user-error-card.tsx#L37
Also, this is most likely a 5XX error, as there is likely a misconfiguration.
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.
ah i see, yeah we will then need to adjust ory/elements and move the logic at some point to the hosted ui rather.
elements should just render what it is given.
Related to ory/network#325
Related Issue or Design Document
Checklist
If this pull request addresses a security vulnerability,
I confirm that I got approval (please contact [email protected]) from the maintainers to push the changes.
Further comments