Skip to content

Commit d9cd001

Browse files
authored
Merge pull request #94 from flohdez/8.next-cake5
Add the ability to use a callback in bypassAuth in permissions
2 parents f3f1327 + 6a9e354 commit d9cd001

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ jobs:
1616
prefer-lowest: ['']
1717

1818
steps:
19-
- name: Setup MySQL latest
19+
- name: Setup MySQL 8.0
2020
if: matrix.db-type == 'mysql'
21-
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin
21+
run: |
22+
sudo service mysql start
23+
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
2224
2325
- name: Setup PostgreSQL latest
2426
if: matrix.db-type == 'pgsql'

src/Rbac/Rbac.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ protected function _matchPermission(array $permission, array|ArrayAccess $user,
170170
'action' => $params['action'] ?? null,
171171
'role' => $role,
172172
];
173-
if (!$user && ($permission['bypassAuth'] ?? false) !== true) {
173+
$bypass = $permission['bypassAuth'] ?? false;
174+
if (is_callable($bypass)) {
175+
$bypass = $bypass($user, $role, $request);
176+
}
177+
if (!$user && $bypass !== true) {
174178
return null;
175179
}
176180
foreach ($permission as $key => $value) {

0 commit comments

Comments
 (0)