Closed xdiegom closed 1 year ago
Thanks for your pull request to Laravel!
Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.
If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!
If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.
Hi @taylorotwell,
Thanks for your feedback.
Just realized that I didn't understand the documentation about Default Scopes until now and either Passport::tokensCan()
and Passport::defaultScope()
must co-exists in the AuthServiceProvider in order to work, in other words Passport::setDefaultScope()
can't be defined in AuthServiceProvider
by itself unless Passport::tokensCan()
is declared/defined before, which is something that in the Default Scopes documentation section does not say directly, it has to be inferred in the example and with knowledge of OAuth2, I guess.
I wanted to make it clear in order to definitely close this issue in case someone find this useful and maybe my solution could help to make it as a package or in future references for Laravel ๐๐ผ
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.