Skip to content

Add Scopes to grant resources by scope roles - #34

Closed
ievgeniiskliarenko wants to merge 1 commit into
masterfrom
access/scope-roles
Closed

ievgeniiskliarenko wants to merge 1 commit into
masterfrom
access/scope-roles

Conversation

@ievgeniiskliarenko

Copy link
Copy Markdown
Contributor

A client can get a scope just by having the same name as that scope. virtue-access's User automatically adds its own name to its roles: new User('read-catalog', []); // roles: ['read-catalog']

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Prefixed client names and unknown scopes can still bypass authorization.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Adds scope-to-role/resource helpers for role-based access control.

Changes:

  • Introduces prefixed scope roles and resource grants.
  • Adds unit and authorization tests.
File Description
src/​Access/​Scopes.php Implements scope mapping helpers.
tests/​Access/​ScopesTest.php Tests scope conversion and access behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

*/
class Scopes
{
public const ROLE_PREFIX = 'scope:';
Comment on lines +46 to +47
foreach ($scopes as $scope) {
$roles[self::resource($scope)] = self::asRoles([$scope]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants