PermissionSet
The resolved authorization state for one request: the flat list of {@see GrantedPermission}s the resolver produced, plus the `'*'` superuser grant if the actor held it. Answers "can this actor do * X?" ({@see self::can()}) and "why?" ({@see self::sourcesOf()}). It may hold the same permission from more than one source (a role AND a flat scope) — that is what makes authorization explainable. Immutable by construction.
PermissionSet::__construct()
public function __construct(array $granted, bool $grantsAll = false, ?Milpa\Auth\PermissionSource $allSource = null):Parameters
| Name | Type | Description |
|---|---|---|
| $granted | list<GrantedPermission> | every permission granted, with its provenance |
| $grantsAll | bool | true when the actor holds the `'*'` scope (grants all) |
| $allSource | ?PermissionSource | provenance of the `'*'` grant, when $grantsAll |
PermissionSet::can()
public function can(string $resource, string $action, ?string $namespace = null): boolWhether the actor can perform $action on $resource (optionally scoped to $namespace). See {@see self::allows()}.
Parameters
| Name | Type | Description |
|---|---|---|
| $resource | string | |
| $action | string | |
| $namespace | ?string |
PermissionSet::allows()
public function allows(Milpa\Auth\Permission $permission): boolWhether $permission is granted — true if `'*'` was granted, else an exact key match. No glob.
Parameters
| Name | Type | Description |
|---|---|---|
| $permission | Milpa\Auth\Permission |
PermissionSet::all()
public function all(): arrayPermissionSet::sourcesOf()
public function sourcesOf(Milpa\Auth\Permission $permission): arrayEvery source that granted $permission (each path, not deduped), preceded by the `'*'` source when this set grants all. Empty when $permission is not granted.
Parameters
| Name | Type | Description |
|---|---|---|
| $permission | Milpa\Auth\Permission |
PermissionSet::grantsAll()
public function grantsAll(): bool