From 1035a03221fbac4af02ffe8980200e4f53d5aa28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florencio=20Hern=C3=A1ndez?= Date: Tue, 17 Sep 2024 12:14:45 +0100 Subject: [PATCH 1/2] Add the ability to use a callback in bypassAuth in permissions --- src/Rbac/Rbac.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Rbac/Rbac.php b/src/Rbac/Rbac.php index 57faf7e..2f82464 100644 --- a/src/Rbac/Rbac.php +++ b/src/Rbac/Rbac.php @@ -170,7 +170,11 @@ protected function _matchPermission(array $permission, array|ArrayAccess $user, '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) { From 6a9e35450c5a97e0c7af826ec9840bdce132f623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florencio=20Hern=C3=A1ndez?= Date: Mon, 16 Dec 2024 11:15:19 +0000 Subject: [PATCH 2/2] Update ci.yml --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1ce7f5..1393ae9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,9 +16,11 @@ jobs: prefer-lowest: [''] steps: - - name: Setup MySQL latest + - name: Setup MySQL 8.0 if: matrix.db-type == 'mysql' - 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 + run: | + sudo service mysql start + mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;' - name: Setup PostgreSQL latest if: matrix.db-type == 'pgsql'