API / Minn\Rest / PolicyGate

PolicyGate final readonly class

Minn\Rest\PolicyGate · public/minn/src/Minn/Rest/PolicyGate.php · 176 lines

Judges a route's policy against the caller, with the reference's refusals: a caller who is not signed in gets the policy's sign-in code at 401, a bad nonce is always 403 rest_cookie_invalid_nonce, and a signed-in caller who lacks a capability gets the refusal code at 403. A subject the policy names is looked up first and answers its 404 before any of those. The edit-context policy, when the request asks for it, is judged before the route's own, as the reference refuses the context first (the menus).

Used by 1

Constants and properties

privatereadonly Minn\Rest\Caller $caller

Promoted from the constructor.

privatereadonly Minn\Rest\Subjects $subjects

Promoted from the constructor.

privatereadonly Minn\Rest\Types $types

Promoted from the constructor.

Public

new__construct(Minn\Rest\Caller $caller, Minn\Rest\Subjects $subjects, Minn\Rest\Types $types)#
methodclosure(): Closure#

The judge as the router takes it.

methodjudge(Minn\Http\Policy $policy, Minn\Http\Request $request, array $captures): void#

Throws the refusal the policy names, or returns.

$capturesarray<string, string>

Internals 7

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatesubject(Minn\Http\Policy $policy, array $captures): void#

The record's 404 when it does not exist. "me" names the caller, who must then be signed in; the reference answers that with its plain sign-in refusal whatever the route's own code is.

$capturesarray<string, string>
privatetype(Minn\Http\Policy $policy, array $captures): void#

A {base} that names no declared type declines the route, so the next one may take it. A write is judged with the type's own capabilities (probe rest-plugin-caps): a missing post first (404), then the caller (401 signed out, 403 refused).

$capturesarray<string, string>
privatetaxonomy(Minn\Http\Policy $policy, array $captures): void#

A {base} that names no registered taxonomy declines the route. A write is judged with the taxonomy's own capabilities (probe rest-plugin-caps): a missing term first (404), then the caller.

$capturesarray<string, string>
privateopened(array $opener, Minn\Http\Request $request): bool#

Whether a policy's opener lets any caller through: the filter it names, handed false, the request, and the controller the reference passes, by its kind (built with the argument given).

$openerarray{0: string, 1: string, 2?: string}
privatecapabilities(Minn\Http\Policy $policy): void#
privateregistered(Minn\Http\Policy $policy, string $capability): string#

A capability as the post type or taxonomy the policy names registered it, or as given.

privateown(Minn\Http\Policy $policy, array $captures): void#
$capturesarray<string, string>