Policy final readonly class
Minn\Http\Policy · public/minn/src/Minn/Http/Policy.php · 115 lines
What a route requires of its caller, as data on the route: the router enforces it before the handler runs, so a grep over the attributes is the authorization surface. The two refusals are the reference's: a caller who is not signed in gets the sign-in code (401), a signed-in caller who lacks the capability gets the refusal code (403); how a bad nonce is answered belongs to whoever judges the policy. A policy that names a subject has the record looked up first, and answers the record's 404 before either refusal, which is the reference's order.
Written inline in the attribute with `new`, which is what an attribute argument allows: `policy: new Policy(Access::Cap, 'upload_files', refuse: 'rest_cannot_create', message: '...')`.
Used by 53 (show)
Constants and properties
| prop | readonly Minn\Http\Access $access | Promoted from the constructor. |
| prop | readonly ?string $cap | Promoted from the constructor. |
| prop | readonly array $caps | Promoted from the constructor. |
| prop | readonly ?string $param | Promoted from the constructor. |
| prop | readonly string $signIn | Promoted from the constructor. |
| prop | readonly string $signInMessage | Promoted from the constructor. |
| prop | readonly string $refuse | Promoted from the constructor. |
| prop | readonly string $message | Promoted from the constructor. |
| prop | readonly ?Minn\Http\Policy $edit | Promoted from the constructor. |
| prop | readonly ?Minn\Http\Subject $subject | Promoted from the constructor. |
| prop | readonly ?string $missing | Promoted from the constructor. |
| prop | readonly ?string $missingMessage | Promoted from the constructor. |
| prop | readonly int $signInStatus | Promoted from the constructor. |
| prop | readonly ?string $verb | Promoted from the constructor. |
| prop | readonly ?array $opener | Promoted from the constructor. |
Public
| new | __construct(Minn\Http\Access $access = Minn\Http\Access::Public, ?string $cap = NULL, array $caps = array ( ), ?string $param = NULL, string $signIn = 'rest_not_logged_in', string $signInMessage = 'You are not currently logged in.', string $refuse = 'rest_forbidden', string $message = 'Sorry, you are not allowed to do that.', ?Minn\Http\Policy $edit = NULL, ?Minn\Http\Subject $subject = NULL, ?string $missing = NULL, ?string $missingMessage = NULL, int $signInStatus = 401, ?string $verb = NULL, ?array $opener = NULL)# |
| ||||||||||||||||||||||||
| method | isPublic(): bool# | Whether the route is open to anyone with nothing to look up, so the gate need not run at all. | ||||||||||||||||||||||||
| method | missingCode(): string# | The 404 code a missing subject earns. | ||||||||||||||||||||||||
| method | missingText(): string# | The 404 message a missing subject earns. | ||||||||||||||||||||||||
| method | capabilities(): array# | Every capability the policy asks for by name, the one on the object included, so a listing can show what a route takes. @return list<string> | ||||||||||||||||||||||||
| method | toArray(): array# | The policy as data, for the route catalogue. @return array<string, mixed> @return array<string, mixed> | ||||||||||||||||||||||||
| method | describe(): string# | The policy in one line, for the route index and the docs. |
Nothing matches.