oauth2-php
oauth2-php copied to clipboard
Honor request's scope value
In the OAuth2 spec on granting an access token, "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".
So OAuth2 spec doesn't have an opinion on how scope is being handled. But oauth2-php currently has an opinion: fully ignores the request's scope value.
As a result, there is at least one use case that's impossible:
- a client with a 'client_credentials' grant type has both 'read' and 'write' scope.
- the client wants to get an access token that can ONLY 'read' data.
With this PR, the client can ask for an access token of 'read' scope by passing in 'scope=read' in the request.
What's keeping this PR from being merged?
It is currently impossible for a client to request a token with a scope that is narrower than the supported scope.
OK I have understood your PR. I have been working on the policy functionality and it seems to fix your problem.
I have created a related PR (#64) which does the same thing with according tests ;)
This PR might be closed as #64 has been merged. @chuanma Can you confirm that the requested scope is correctly honored?