Gatekeeper
Immutable access control helper.
class GatekeeperThis class determines the user's subjects upon instantiation and stores them for its duration.
- Copyright
- 2015-2016 Appertly
- License
- Apache-2.0
Constructors / Destructors
| Returns | Signature and Description |
|---|---|
void | __construct(, , )Creates a new Gatekeeper. |
Instance Methods
| Returns | Signature and Description |
|---|---|
void | assert(, , )Determines if the currently authenticated user can access the resource. |
void | Determines if the currently authenticated user can access the resources. |
bool | can(, , )Determines if the currently authenticated user can access the resource. |
Method Details
__construct
__construct(Service $aclService, Principal $principal, array<SubjectResolver> $subjectResolvers)Creates a new Gatekeeper.
| Name | Type | Description |
|---|---|---|
$aclService | Service | The ACL service |
$principal | Principal | The authenticated principal |
$subjectResolvers | array<SubjectResolver> | Any additional subject resolvers |
assert
assert(string $verb, string $type, mixed $id)Determines if the currently authenticated user can access the resource.
| Name | Type | Description |
|---|---|---|
$verb | string | The verb (e.g. 'read', 'write') |
$type | string | The type of object |
$id | mixed | The object identifier |
| Type | Conditions |
|---|---|
Forbidden | If the user has no access |
assertAll
assertAll<T>(string $verb, string $type, Traversable<T> $ids)Determines if the currently authenticated user can access the resources.
- Since
- 0.5.1
| Name | Type | Description |
|---|---|---|
$verb | string | The verb (e.g. 'read', 'write') |
$type | string | The type of object |
$ids | Traversable<T> | The object identifiers |
| Type | Conditions |
|---|---|
Forbidden | If the user has no access |
can
can(string $verb, string $type, mixed $id)Determines if the currently authenticated user can access the resource.
| Name | Type | Description |
|---|---|---|
$verb | string | The verb (e.g. 'read', 'write') |
$type | string | The type of object |
$id | mixed | The object identifier |
| Type | Description |
|---|---|
bool | Whether the user has access |