oauth2-server icon indicating copy to clipboard operation
oauth2-server copied to clipboard

Return `scope` as a token response param

Open chervand opened this issue 8 years ago • 6 comments
trafficstars

According to https://tools.ietf.org/html/rfc6749#section-5.1

scope OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED...

and https://tools.ietf.org/html/rfc6749#section-3.3

The authorization server MAY fully or partially ignore the scope requested by the client, based on the authorization server policy or the resource owner's instructions. If the issued access token scope is different from the one requested by the client, the authorization server MUST include the "scope" response parameter to inform the client of the actual scope granted. If the client omits the scope parameter when requesting authorization, the authorization server MUST either process the request using a pre-defined default value or fail the request indicating an invalid scope. The authorization server SHOULD document its scope requirements and default value (if defined).

Is it possible to return scope value as a request param by default to notify clients about actually granted scopes (in case default or omitted ones) without need of parsing JWT?

chervand avatar Oct 11 '17 15:10 chervand

@chervand have you found a way to accomplish this?

DewaldBodenstein avatar Oct 24 '17 10:10 DewaldBodenstein

@DewaldBodenstein, I believe, adding it to a League\OAuth2\Server\ResponseTypes\BearerTokenResponse $responseParams should be enough.

chervand avatar Oct 24 '17 17:10 chervand

Thanks, got it working.

DewaldBodenstein avatar Oct 25 '17 04:10 DewaldBodenstein

@chervand That's nice. I think in most implementations, if the client requests scopes that aren't supported, the server should respond with an invalid_scope error. However, this is really useful for situations where a scope is valid, but for some other reason has been denied (e.g. authorisation).

And as you rightly mention, it follows spec. In fact, I'd go so far as to say that it's worth having in the response regardless.

Do you fancy making a pull request for this?

simonhamp avatar Oct 25 '17 14:10 simonhamp

@simonhamp yes, sure

chervand avatar Oct 25 '17 14:10 chervand

+1, this would be very useful.

christiaangoossens avatar Apr 22 '18 14:04 christiaangoossens