Skip to content
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

Merged
merged 2 commits into from
Aug 16, 2023

Conversation

jonas-jonas
Copy link
Member

@jonas-jonas jonas-jonas commented Aug 10, 2023

Related to ory/network#325

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    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.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

image image

@jonas-jonas jonas-jonas self-assigned this Aug 10, 2023
@jonas-jonas jonas-jonas requested review from Benehiko and aeneasr and removed request for Benehiko August 10, 2023 15:30
}

function isOAuth2Error(query: qs.ParsedQs): query is OAuth2Error {
return query.error !== undefined && query.error_description !== undefined
Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

}

function isOAuth2Error(query: qs.ParsedQs): query is OAuth2Error {
return query.error !== undefined && query.error_description !== undefined
Copy link
Contributor

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

}),
})
} catch (err) {
// The error could not be found or there was an error fetching it, redirect back to home.
res.redirect("welcome")
Copy link
Contributor

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?

Copy link
Member Author

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...

Copy link
Contributor

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.

Copy link
Member Author

@jonas-jonas jonas-jonas Aug 11, 2023

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.

Copy link
Member

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

Copy link
Member Author

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.

@jonas-jonas
Copy link
Member Author

@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?

@Benehiko
Copy link
Contributor

@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

@Benehiko
Copy link
Contributor

Can also override the styling for this in hostedui if you want. I think you should be able to

Copy link
Contributor

@Benehiko Benehiko left a 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
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

@jonas-jonas jonas-jonas merged commit 4937e34 into master Aug 16, 2023
6 checks passed
@jonas-jonas jonas-jonas deleted the jonas-jonas/fixOauth2ErrorMessage branch August 16, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants