AuthenticatorInterface
All authenticators must implement theAuthenticatorInterface.
Methods
authenticate(string $token): ?AbstractAuthIdentity: Takes a raw token (or credential string) and returns an identity object if valid, ornullif authentication fails.
JwtAuthenticator
Apivalk provides a production-readyJwtAuthenticator that uses the firebase/php-jwt library. It is designed to work with OAuth2 providers (like Auth0, Okta, or Keycloak) that expose a JWKS (JSON Web Key Set) endpoint.
Features
- JWKS Support: Automatically fetches and parses public keys from a remote URL.
- Claim Validation: Validates the
iss(issuer),aud(audience), andexp(expiration) claims. A configured issuer or audience has to be present in the token and match; an empty string disables that check. Theaudclaim may be a single string or a list of strings, and matches when the configured audience is among them. - Scope Extraction: Automatically parses scopes from the
scopeorscpclaims. - Identity Creation: Returns a
JwtAuthIdentitypopulated with thesub,email,username,scopes,permissions, and audiences.