WpSessionAuthenticator
in package
implements
RequestAuthenticatorInterface
The batteries-included {@see RequestAuthenticatorInterface}: resolves the user from the established WordPress session (cookie auth) only.
Bearer-token / JWT resolution deliberately lives OUTSIDE the library — that is product logic. A product that exposes a token-authenticated API composes an authenticator that first tries a token, then falls back to this one, and injects the composite into its controllers. This keeps the OSS library free of any product credential logic.
Table of Contents
Interfaces
- RequestAuthenticatorInterface
- Resolves the WordPress user behind an inbound REST request.
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