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

oauth auth service still called even if grant returns an error #3275

Closed
tjenkinson opened this issue Sep 13, 2023 · 2 comments · Fixed by #3284
Closed

oauth auth service still called even if grant returns an error #3275

tjenkinson opened this issue Sep 13, 2023 · 2 comments · Fixed by #3284

Comments

@tjenkinson
Copy link

Steps to reproduce

Expected behavior

If grant returns an error like it can here

https://github.com/simov/grant/blob/6e0692dfdd83edbc4ee82629ba0fe8f986d5879d/lib/flow/oauth2.js#L69

then the auth service should not be called and an error should returned.

Actual behavior

The error is not checked so the code continues with profile and the access token missing.

It also looks like the provided strategy expects profile to be there:

const profile = await this.getProfile(authentication, params)

Would it make sense to bail here if payload.error is set?

const payload = grant?.response || result?.session?.response || result?.state?.response || params.query

@daffl
Copy link
Member

daffl commented Sep 14, 2023

This looks like a really good catch. I bet this is what the issue in #3266 is also about. What's the best way to try and reproduce this?

@tjenkinson
Copy link
Author

Ah yes that looks likely. You can trigger it if you set state: true, and then tweak the state in the url when logging in so that it no longer matches in the callback :)

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 a pull request may close this issue.

2 participants