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.
Added Guide chapter on Identity, Permissions and Scopes #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Added Guide chapter on Identity, Permissions and Scopes #17
Changes from 1 commit
f067836
9165665
a05d085
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is incorrect. As far as I know scopes are attached to access token and not clients.
Scopes are used from very beginning in OAuth 2.
I have used multiple access token with different scopes for same clients.
Example:
My app uses GitHub for login. OAuth 2 login. In addition to email+password. In that my app only request these scopes: read email + read basic profile info. If I login with GitHub I get access token which can only read user email and other basic profile info. With this token I cannot read user's private repo.
After login (by GitHub or email+password) my same app has this functionality: attach GitHub repo
My app allows users to host their project located in GitHub
When My app request GitHub to access repo I also add read_repo scope to the request. This time I get access token which allow me to read repo
So I have total 2 access token with different scopes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for your extensive input.
The scope in the access token depends on the requested scope during the token request. The granting of scope however, is connected to the Client (for the specific user).
https://oauth.net/2/scope/ and https://www.oauth.com/oauth2-servers/scope/defining-scopes/
Does that resolve the concern you raised or did I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& !Yii::$app->getModule('oauth2')->requestHasScope('create_email')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think RBAC authorization and scopes based authorisation are different. We have to apply both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOHELAHMED7 @mtangoo
If I'm not mistaken they are now required both because of the
!
, in other words:If the user does not has the role 'user' or the request does not has the scope 'create_email' then throw the unauthorized exception.