forked from BeWelcome/rox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an implementation to read the existing permissions data (port fro…
…m MOD_rights) Add permission lockdown to the /admin section of website
- Loading branch information
Showing
6 changed files
with
160 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Permissions | ||
|
||
The entire `/admin` section of the site is restricted to users with `ROLE_ADMIN`, | ||
which maps to having the 'Admin' right. The user's roles are loaded upon | ||
login via [Rox\Member\Model\Member](module/Member/src/Model/Member.php)::getRoles() | ||
|
||
This needs to be scaled back to use the correct rights in certain | ||
controllers of the admin section. The `^/admin` line should be removed from | ||
`access_control.global.yml` and permission checks added to controller actions. | ||
|
||
To check for the admin role: | ||
```php | ||
if (!$this->getAuthChecker()->isGranted('ROLE_ADMIN')) { | ||
throw new AccessDeniedHttpException(); | ||
} | ||
``` | ||
|
||
To check for a right: | ||
```php | ||
if (!$this->getMember()->getRightLevel('Logs')) { | ||
throw new AccessDeniedHttpException(); | ||
} | ||
``` | ||
|
||
To check for a right with certain scope: | ||
```php | ||
if (!$this->getMember()->getRightLevel('Words', 'en')) { | ||
throw new AccessDeniedHttpException(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Rox\Auth\Model; | ||
|
||
use Rox\Core\Model\AbstractModel; | ||
|
||
class Right extends AbstractModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $table = 'rights'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Rox\Member\Model; | ||
|
||
use Rox\Auth\Model\Right; | ||
use Rox\Core\Model\AbstractModel; | ||
|
||
/** | ||
* @property Right $right | ||
*/ | ||
class MemberRight extends AbstractModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $table = 'rightsvolunteers'; | ||
|
||
public function right() | ||
{ | ||
return $this->hasOne(Right::class, 'id', 'IdRight'); | ||
} | ||
} |