Add default scopes to issued token #1679
Closed
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.
Hi there,
This PR is related to passport default scopes.
I was working on a project using Laravel Passport and after I register the default scopes in
AuthServiceProvider.php
withPassport::setDefaultScope()
the returned token didn't have the scopes defined in the payload. Thus, I decided to make some changes which are:when validating scopes, Passport should add the
defaultScope
as part of the validationhasScope()
and methods likescopeIds()
andscopes()
. For that matter, I added a new Passport static method calleduseDefaultScopes()
that sets a boolean static attribute to true in case default scopes MAY want to be included in issued token.For this, I am not quite sure if this method is useful and always add default scopes if
defaultScope
is not empty 🤔 trying to adhere to the RFC fragment I addressed in this numeral.Passport::$defaultScope
should follow the same data type asPassport::$scopes
regarding of one of the reasons of what scopes are for: "displaying the description on the authorization approval screen"Hope this helps 😃, if this PR is approved, I think that the only part where Laravel Passport docs may change is here Default Scope and also within an upgrade docs.