RequestAuthenticatorInterface
in
Resolves the WordPress user behind an inbound REST request.
This is the injected seam a controller's permission callbacks depend on, in place of the old static auth middleware. The library ships a WordPress-session binding (WpSessionAuthenticator); a product that also accepts API bearer tokens composes its own binding (e.g. one backed by a JWT token service) and injects that instead — the library itself carries no product token logic.
Table of Contents
Methods
- isAdmin() : bool
- Whether the user behind the request is a site administrator.
- resolveUser() : null|WP_Error|WP_User
- Resolve the user behind the request.
Methods
isAdmin()
Whether the user behind the request is a site administrator.
public
isAdmin(WP_REST_Request $request) : bool
Backs AbstractWpRestController::adminPermissionCheck()
only. #[Auth] capabilities are checked capability by capability with
user_can() on the resolved user, never through this method.
Parameters
- $request : WP_REST_Request
Return values
boolresolveUser()
Resolve the user behind the request.
public
resolveUser(WP_REST_Request $request) : null|WP_Error|WP_User
Parameters
- $request : WP_REST_Request
Return values
null|WP_Error|WP_User —a WP_User when authenticated; a WP_Error when a presented credential was rejected (the error is surfaced to the caller as-is); null when the request is simply anonymous