Fix refresh tokens with dynamic scopes - #1754
Merged
nbulaj merged 1 commit intoDec 6, 2024
Merged
Conversation
stanhu
force-pushed
the
sh-fix-refresh-token-with-dynamic-scopes
branch
from
December 4, 2024 22:18
fa75b04 to
707b393
Compare
Contributor
Author
|
@nbulaj Just one small fix we ran into while trying to use dynamic scopes. Could you review? |
nbulaj
reviewed
Dec 5, 2024
stanhu
force-pushed
the
sh-fix-refresh-token-with-dynamic-scopes
branch
from
December 5, 2024 13:22
707b393 to
8be888e
Compare
Suppose your OAuth application supports the scopes `public user:*`. Previously a refresh token with the `public user:1` scope returned a scope of `public` by default, unless `user:1` were explicitly requested. This happened because `Doorkeeper::Oauth::BaseRequest` does a set intersection: "public user:*" & "public user:1" = "public" With dynamic scopes, this doesn't work because the wildcard `user:*` doesn't match `user:1`. To fix this, introduce `Scopes#allowed` and deprecate the use of `&`.
stanhu
force-pushed
the
sh-fix-refresh-token-with-dynamic-scopes
branch
from
December 5, 2024 13:23
8be888e to
e2b8dab
Compare
Contributor
Author
|
@nbulaj Thanks so much again! Sorry to bother you again, but would you be so kind to tag a new release? Thanks again for your work on this project. |
Member
|
Hey @stanhu , already released ☝️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Suppose your OAuth application supports the scopes
public user:*. Previously a refresh token with thepublic user:1scope returned a scope ofpublicby default, unlessuser:1were explicitly requested. This happened becauseDoorkeeper::Oauth::BaseRequestdoes a set intersection:With dynamic scopes, this doesn't work because the wildcard
user:*doesn't matchuser:1.To fix this, introduce
Scopes#allowedand deprecate the use of&.