Problem/Motivation

When using an OAuth client that uses a dynamic scope based upon a user role, If that role has an implicit permission applied to it, it will no longer be respected

Steps to reproduce

1. Create an OAuth Scope with a role granularity, with a role of anything other than anonymous or authenticated
1. Apply the permission "access content" to the "Authenticated User" role and not that selected role
2. Attempt to view a node / taxonomy item via the JSON API using an OAuth access token
3. 403 will be returned

Proposed resolution

The original Drupal\simple_oauth\Plugin\ScopeGranularity\Role::hasPermission() function will check both the users role and AccountInterface::AUTHENTICATED_ROLE to see if the permission exists when the role being checked wasn't anonymous or authenticated, but in the refactored version, the new getRoles() function doesn't do this and will only check the explicit role of the scope.

Adding AccountInterface::AUTHENTICATED_ROLE to the returned roles when the role isint Anonymous or Authenticated in the new Drupal\simple_oauth\Plugin\ScopeGranularity\Role::getRoles() function solves this issue.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tylermc created an issue. See original summary.

tylermc’s picture

Hi,

I've added the fix to the MR which now should better reflect the original functionality of the simple_oauth module.

Using this patch fixes my issue on our Drupal Install.

Cheers

bojan_dev made their first commit to this issue’s fork.

  • bojan_dev committed 041aaf93 on 6.0.x authored by tylermc
    [#3555151] fix: Implicit permissions given to roles from the "...
bojan_dev’s picture

Status: Active » Fixed
Issue tags: +6.0.8

Nice catch @tylermc, merged and tagged in 6.0.8.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.