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' 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) {