Skip to content

Commit

Permalink
Add the ability to use a callback in bypassAuth in permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
flohdez committed Sep 17, 2024
1 parent 91fede5 commit 0aa5317
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Rbac/Rbac.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ protected function _matchPermission(array $permission, $user, $role, ServerReque
'action' => $params['action'] ?? null,
'role' => $role,
];
if (!$user && ($permission['bypassAuth'] ?? false) !== true) {
$bypass = $permission['bypassAuth'] ?? false;
if (is_callable($bypass)) {
$bypass = $bypass($user, $role, $request);
}
if (!$user && $bypass !== true) {
return null;
}
foreach ($permission as $key => $value) {
Expand Down

0 comments on commit 0aa5317

Please sign in to comment.