Skip to content
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

Added Guide chapter on Identity, Permissions and Scopes #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rhertogh
Copy link
Owner

@rhertogh rhertogh commented Aug 6, 2023

Based on #12 (comment)

@rhertogh rhertogh self-assigned this Aug 6, 2023
@rhertogh rhertogh added the documentation Improvements or additions to documentation label Aug 6, 2023
@rhertogh rhertogh changed the title Added Guide chaperter on Identity, Permissions and Scopes Added Guide chapter on Identity, Permissions and Scopes Aug 6, 2023
@rhertogh
Copy link
Owner Author

rhertogh commented Aug 6, 2023

@mtangoo @SOHELAHMED7 I've added a chapter in the guide on Identity, Permissions and Scopes.
If you have the time, a proof reading/feedback would be highly appreciated.

Copy link
Contributor

@mtangoo mtangoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With comments I have put I think it is good

docs/guide/start-identity-permissions-and-scopes.md Outdated Show resolved Hide resolved

> Note: Until now "scope" is never used and probably is not needed.
Only when we have multiple clients, let's say FEA1 and FEA2, that need a different access scope for the *same* user,
scopes come into play.
Copy link
Contributor

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.

Copy link
Owner Author

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?

{
if (
!Yii::$app->user->can('user')
|| !Yii::$app->getModule('oauth2')->requestHasScope('create_email')
Copy link
Contributor

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')`

&& !Yii::$app->getModule('oauth2')->requestHasScope('create_email')

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true.

Copy link
Owner Author

@rhertogh rhertogh Oct 31, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants