Skip to content

Commit

Permalink
Bugfix on Symfony Role mapping
Browse files Browse the repository at this point in the history
* Roles must be prefixed with `ROLE_` for Symfony to support them
* Use resource name vs last account-name
* Assign roles as strings vs Role instances
  • Loading branch information
joostfaassen committed Sep 27, 2015
1 parent 0663971 commit 1b12e62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Client.php
Expand Up @@ -71,7 +71,7 @@ public function getUserByUsername($username)
foreach ($policyData['action'] as $action) {
$policy->addAction($action);
if ($policy->getEffect() == 'allow') {
$roleName = 'xrn:' . $this->partition . ':userbase::account/' . $account->getName();
$roleName = 'ROLE_' . $policy->getResource();
$roleName .= '@' . $action;
$user->addRole($roleName);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Model/User.php
Expand Up @@ -245,7 +245,6 @@ public function getPolicies()

public function addRole($roleName)
{
$role = new Role($roleName);
$this->roles[] = $role;
$this->roles[] = $roleName;
}
}

0 comments on commit 1b12e62

Please sign in to comment.