Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 102b165

Browse files
authoredSep 11, 2023
Merge pull request #14 from php-casbin/develop
BREAKING CHANGE: change namespace to Cake\Permission and support cakephp 5.0
2 parents 92a84f3 + c45419a commit 102b165

File tree

12 files changed

+39
-4177
lines changed

12 files changed

+39
-4177
lines changed
 

‎.github/workflows/build.yml renamed to ‎.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: test
22

33
on:
44
push:
@@ -15,22 +15,22 @@ jobs:
1515
image: mysql:5.7
1616
env:
1717
MYSQL_ALLOW_EMPTY_PASSWORD: yes
18-
MYSQL_DATABASE: cake_adapter
18+
MYSQL_DATABASE: cake-permission
1919
ports:
2020
- 3306:3306
2121
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
2222

2323
strategy:
2424
fail-fast: true
2525
matrix:
26-
php: [ 7.3, 7.4 ]
27-
stability: [ prefer-lowest, prefer-stable ]
26+
php: [7.3, 7.4, 8.0, 8.1, 8.2]
27+
stability: [prefer-stable]
2828

2929
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
3030

3131
steps:
3232
- name: Checkout code
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3434

3535
- name: Setup PHP
3636
uses: shivammathur/setup-php@v2
@@ -73,10 +73,10 @@ jobs:
7373
runs-on: ubuntu-latest
7474
needs: [ test, upload-coverage ]
7575
steps:
76-
- uses: actions/checkout@v2
77-
- uses: actions/setup-node@v1
76+
- uses: actions/checkout@v3
77+
- uses: actions/setup-node@v3
7878
with:
79-
node-version: '14.17'
79+
node-version: 'lts/*'
8080

8181
- name: Run semantic-release
8282
env:

‎.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ composer.lock
77
*.iml
88

99
# coverage report
10-
/build
10+
/build
11+
12+
.phpunit.result.cache

‎README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Cake-Casbin
1+
# Cake-Permission
22

3-
[![Latest Stable Version](https://poser.pugx.org/casbin/cake-adapter/v/stable)](https://packagist.org/packages/casbin/cake-adapter)
4-
[![Total Downloads](https://poser.pugx.org/casbin/cake-adapter/downloads)](https://packagist.org/packages/casbin/cake-adapter)
5-
[![License](https://poser.pugx.org/casbin/cake-adapter/license)](https://packagist.org/packages/casbin/cake-adapter)
3+
[![Test](https://github.com/php-casbin/cake-permission/workflows/build/badge.svg?branch=master)](https://github.com/php-casbin/cake-permission/actions)
4+
[![Coverage Status](https://coveralls.io/repos/github/php-casbin/cake-permission/badge.svg)](https://coveralls.io/github/php-casbin/cake-permission)
5+
[![Latest Stable Version](https://poser.pugx.org/casbin/cake-adapter/v/stable)](https://packagist.org/packages/casbin/cake-permission)
6+
[![Total Downloads](https://poser.pugx.org/casbin/cake-adapter/downloads)](https://packagist.org/packages/casbin/cake-permission)
7+
[![License](https://poser.pugx.org/casbin/cake-adapter/license)](https://packagist.org/packages/casbin/cake-permission)
68

79
Use Casbin in CakePHP Framework, Casbin is a powerful and efficient open-source access control library.
810

@@ -11,7 +13,7 @@ Use Casbin in CakePHP Framework, Casbin is a powerful and efficient open-source
1113
Require this package in the `composer.json` of your CakePHP project. This will download the package.
1214

1315
```
14-
composer require casbin/cake-adapter
16+
composer require casbin/cake-permission
1517
```
1618

1719
create config file `config/casbin.php` for Casbin:
@@ -32,7 +34,7 @@ return [
3234
],
3335

3436
// Cake-casbin adapter .
35-
'adapter' => '\CasbinAdapter\Cake\Adapter',
37+
'adapter' => '\Cake\Permission\Adapter',
3638

3739
/*
3840
* Cake-casbin database setting.
@@ -72,7 +74,7 @@ $sub = 'alice'; // the user that wants to access a resource.
7274
$obj = 'data1'; // the resource that is going to be accessed.
7375
$act = 'read'; // the operation that the user performs on the resource.
7476

75-
$casbin = new \CasbinAdapter\Cake\Casbin();
77+
$casbin = new \Cake\Permission\Casbin();
7678

7779
if (true === $casbin->enforce($sub, $obj, $act)) {
7880
// permit alice to read data1

‎composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
"description": "Use casbin in CakePHP. ",
55
"authors": [
66
{
7-
"name": "TechLee",
8-
"email": "techlee@qq.com"
7+
"name": "JonLee",
8+
"email": "leeqvip@gmail.com"
99
}
1010
],
1111
"license": "Apache-2.0",
1212
"require": {
1313
"php": ">=7.2.0",
14-
"cakephp/cakephp": "~4.0",
14+
"cakephp/cakephp": "~4.0|~5.0",
1515
"casbin/casbin": "~3.1"
1616
},
1717
"require-dev": {
1818
"phpunit/phpunit": "~8.5.0 || ^9.3"
1919
},
2020
"autoload": {
2121
"psr-4": {
22-
"CasbinAdapter\\Cake\\": "src/"
22+
"Cake\\Permission\\": "src/"
2323
}
2424
}
2525
}

‎composer.lock

Lines changed: 0 additions & 4142 deletions
This file was deleted.

‎config/casbin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313

1414
// Cake-casbin adapter .
15-
'adapter' => '\CasbinAdapter\Cake\Adapter',
15+
'adapter' => '\Cake\Permission\Adapter',
1616

1717
/*
1818
* Cake-casbin database setting.

‎src/Adapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CasbinAdapter\Cake;
3+
namespace Cake\Permission;
44

55
use Casbin\Exceptions\CasbinException;
66
use Casbin\Persist\Adapter as AdapterContract;
@@ -12,7 +12,7 @@
1212
use Casbin\Exceptions\InvalidFilterTypeException;
1313
use Casbin\Persist\AdapterHelper;
1414
use Cake\ORM\TableRegistry;
15-
use CasbinAdapter\Cake\Model\Table\CasbinRuleTable;
15+
use Cake\Permission\Model\Table\CasbinRuleTable;
1616

1717
/**
1818
* Adapter.

‎src/Casbin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CasbinAdapter\Cake;
3+
namespace Cake\Permission;
44

55
use Casbin\Model\Model;
66
use Casbin\Enforcer;

‎src/Model/Entity/CasbinRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CasbinAdapter\Cake\Model\Entity;
3+
namespace Cake\Permission\Model\Entity;
44

55
use Cake\ORM\Entity;
66

‎src/Model/Table/CasbinRuleTable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace CasbinAdapter\Cake\Model\Table;
3+
namespace Cake\Permission\Model\Table;
44

55
use Cake\ORM\Table;
6-
use CasbinAdapter\Cake\Model\Entity\CasbinRule;
6+
use Cake\Permission\Model\Entity\CasbinRule;
77

88
class CasbinRuleTable extends Table
99
{

‎tests/DatabaseAdapterTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace CasbinAdapter\Cake\Tests;
3+
namespace Cake\Permission\Tests;
44

55
use PHPUnit\Framework\TestCase;
66
use \Cake\ORM\TableRegistry;
77
use Cake\Datasource\ConnectionManager;
8-
use CasbinAdapter\Cake\Casbin;
8+
use Cake\Permission\Casbin;
99
use Casbin\Persist\Adapters\Filter;
1010
use Casbin\Exceptions\InvalidFilterTypeException;
1111
use Cake\Core\Configure;
@@ -39,11 +39,11 @@ protected function initConfig()
3939
'className' => 'Cake\Database\Connection',
4040
'driver' => 'Cake\Database\Driver\Mysql',
4141
'persistent' => false,
42-
'host' => '127.0.0.1',
43-
'username' => 'root',
44-
'password' => '',
45-
'port' => '3306',
46-
'database' => 'cake_adapter',
42+
'host' => getenv('DB_HOST') ? getenv('DB_HOST') : '127.0.0.1',
43+
'username' => getenv('DB_USERNAME') ? getenv('DB_USERNAME') : 'root',
44+
'password' => getenv('DB_PASSWORD') ? getenv('DB_PASSWORD') : '',
45+
'port' => getenv('DB_PORT') ? getenv('DB_PORT') : '3306',
46+
'database' => getenv('DB_DATABASE') ? getenv('DB_DATABASE') : 'cake-permission',
4747
'encoding' => 'utf8mb4',
4848
'timezone' => 'UTC',
4949
'cacheMetadata' => false,

‎tests/casbin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414

1515
// Cake-casbin adapter .
16-
'adapter' => '\CasbinAdapter\Cake\Adapter',
16+
'adapter' => '\Cake\Permission\Adapter',
1717

1818
/*
1919
* Cake-casbin database setting.

0 commit comments

Comments
 (0)
Please sign in to comment.