Guard that requires a policy ability. Returns 501 when no authorization
policy service is registered, 401 when the ability denies an anonymous
request, 403 when it denies a signed-in principal; otherwise calls
next(). On every refusal the handler and later middleware do not run.
The policy is evaluated BY NAME through the registered
IAuthorizationPolicyService, so a replacement provider serves the guard.
AuthPlugin refuses to start when a route's guard names a policy or ability
that is not registered — or whose registered ability disagrees with this
object on anonymous, which is how a different policy registered under the
same name is caught. Not scanned: a route added after start(), and a
guard added as global middleware; an unknown name there rejects per request
(fail closed).
An anonymous request to an ability that needs a principal is refused 401
BEFORE the extractor runs, so an unauthenticated caller can neither cost a
record lookup nor learn from the extractor whether a record exists. A target
extractor's throw propagates unchanged, so errorHandler answers a database
outage 503 rather than a misleading 403; the handler never runs.
Guard that requires a policy ability. Returns
501when no authorization policy service is registered,401when the ability denies an anonymous request,403when it denies a signed-in principal; otherwise callsnext(). On every refusal the handler and later middleware do not run.The policy is evaluated BY NAME through the registered
IAuthorizationPolicyService, so a replacement provider serves the guard. AuthPlugin refuses to start when a route's guard names a policy or ability that is not registered — or whose registered ability disagrees with this object onanonymous, which is how a different policy registered under the same name is caught. Not scanned: a route added afterstart(), and a guard added as global middleware; an unknown name there rejects per request (fail closed).An anonymous request to an ability that needs a principal is refused
401BEFORE the extractor runs, so an unauthenticated caller can neither cost a record lookup nor learn from the extractor whether a record exists. A target extractor's throw propagates unchanged, soerrorHandleranswers a database outage503rather than a misleading403; the handler never runs.