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

feat: Add scope in restore for OAuth2PasswordGrant #2813

Conversation

bpetetot
Copy link
Contributor

@bpetetot bpetetot commented Sep 3, 2024

I'm currently using the OAuth2PasswordGrant authenticator.

I'd like to use the scope property:

  • The scope property is correctly passed to the authenticate method of OAuth2PasswordGrant.

  • But it is not passed to the restore method when refreshing the access token. The specification says that it is possible to pass an optional scope parameter to the token refresh request. rfc6749

SCR-20240903-papt

So I made this PR (including tests) to add the scope property to the refresh request.

Thanks for the review and ember-simple-auth 🙂

@BobrImperator
Copy link
Collaborator

Hi, thanks for the PR.
It seems like some tests are failing, some fails are expected e.g. ember-beta, ember-release but ember-4.0 should be passing.

@bpetetot bpetetot force-pushed the add-scope-in-restore-of-oauth2-password-grant-authenticator branch from 80e9f71 to 02d477c Compare September 4, 2024 08:16
@bpetetot
Copy link
Contributor Author

bpetetot commented Sep 4, 2024

I've fixed the code and the tests are now passing (locally on ember-4.0)
I've also added some tests about the scope in the module('#_refreshAccessToken') part.

I hope all tests will run now :)

@BobrImperator
Copy link
Collaborator

BobrImperator commented Sep 4, 2024

The tests seem fine 👍

Something I just started wondering about is that we should maybe include a feature flag for this?
My reasoning is that the scope is optional and as I understand not including scope means we're requesting a refresh for the same scope as on initial authorization request.

Ultimately I think that this change might be breaking since the expectation is that we don't send it, whereas this change will send it always.

@bpetetot
Copy link
Contributor Author

bpetetot commented Sep 4, 2024

You're right, a feature flag might be needed to avoid a potential break in some cases.

I've added a refreshAccessTokensWithScope property on OAuth2PasswordGrant which is false by default (I can change the name if necessary).

All operations concerning the scope in the refreshAccessToken function are only activated if the refreshAccessTokensWithScope property is true. I've updated the tests accordingly.

I'm not sure how I should update the documentation on this, I've just added the JSDoc on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants