-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
182 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[request_definition] | ||
r = sub, obj, act | ||
r2 = sub, obj, act | ||
|
||
[policy_definition] | ||
p = sub, obj, act | ||
p2= sub_rule, obj, act, eft | ||
|
||
[role_definition] | ||
g = _, _ | ||
|
||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
|
||
[matchers] | ||
#RABC | ||
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act | ||
#ABAC | ||
m2 = eval(p2.sub_rule) && r2.obj == p2.obj && r2.act == p2.act |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
p, data2_admin, data2, read | ||
p2, r2.sub.Age > 18 && r2.sub.Age < 60, /data1, read, allow | ||
p2, r2.sub.Age > 60 && r2.sub.Age < 100, /data1, read, deny | ||
|
||
g, alice, data2_admin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Casbin; | ||
|
||
/** | ||
* Class EnforceContext | ||
* EnforceContext is used as the first element of the parameter "rvals" in method "enforce" | ||
* | ||
* @author ab1652759879@gmail.com | ||
*/ | ||
class EnforceContext | ||
{ | ||
/** | ||
* rType | ||
* | ||
* @var string | ||
*/ | ||
public $rType; | ||
/** | ||
* pType | ||
* | ||
* @var string | ||
*/ | ||
public $pType; | ||
/** | ||
* eType | ||
* | ||
* @var string | ||
*/ | ||
public $eType; | ||
/** | ||
* mType | ||
* | ||
* @var string | ||
*/ | ||
public $mType; | ||
|
||
/** | ||
* Create a default structure based on the suffix | ||
* | ||
* @param string $suffix | ||
*/ | ||
public function __construct(string $suffix) | ||
{ | ||
$this->rType = "r" . $suffix; | ||
$this->pType = "p" . $suffix; | ||
$this->eType = "e" . $suffix; | ||
$this->mType = "m" . $suffix; | ||
} | ||
} |
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