Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from php-casbin/analysis-zYp1Wo
Apply fixes from StyleCI
- Loading branch information
Showing
10 changed files
with
36 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
<?php | ||
|
||
require_once './vendor/autoload.php'; | ||
|
||
use Casbin\Enforcer; | ||
use Casbin\Util\Log; | ||
|
||
Log::$enableLog = true; | ||
|
||
$e = new Enforcer(__DIR__ . '/examples/modelandpolicy/basic_model.conf', __DIR__ . "/examples/modelandpolicy/basic_policy.csv"); | ||
$e = new Enforcer(__DIR__.'/examples/modelandpolicy/basic_model.conf', __DIR__.'/examples/modelandpolicy/basic_policy.csv'); | ||
|
||
$sub = "alice"; // 想要访问资源的用户。$cfg | ||
$obj = "data1"; // 将被访问的资源。buildRoleLinks | ||
$act = "read"; // 用户对资源执行的操作。 | ||
$sub = 'alice'; // 想要访问资源的用户。$cfg | ||
$obj = 'data1'; // 将被访问的资源。buildRoleLinks | ||
$act = 'read'; // 用户对资源执行的操作。 | ||
|
||
if ($e->enforce($sub, $obj, $act) === true) { | ||
// 允许 alice 读取 data1 | ||
echo "允许 alice 读取 data1"; | ||
echo '允许 alice 读取 data1'; | ||
} else { | ||
// 拒绝请求, 显示错误 | ||
echo "拒绝请求, 显示错误"; | ||
echo '拒绝请求, 显示错误'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters