AH JWT Auth
This plugin allows sign in to WordPress using a JSON Web Token (JWT) contained in a HTTP Header that is added by a reverse proxy that sits in front of your WordPress deployment. Authentication and optionally role assignment is handled by claims contained in the JWT. If configured, the plugin also va
This plugin allows sign in to WordPress using a JSON Web Token (JWT) contained in a HTTP Header that is added by a reverse proxy that sits in front of your WordPress deployment.
Authentication and optionally role assignment is handled by claims contained in the JWT.
If configured, the plugin also validates the JWT aud and iss claims against the expected application audience and JWT issuer values.
Verification of the JWT is handled by either:
- a shared secret for HS256 (as per RFC 7518 this must be at least 256-bits in size)
- a PEM encoded public key for RS256
- retrieving a JSON Web Key Set (JWKS) from a configured URL (also for RS256)
During the login process if the user does not exist an account will be created with a matching role from the JWT, unless automatic user creation has been disabled in the plugin settings.
If the JWT did not contain a role claim then user is created with the role set in the plugin settings (by default this is the subscriber role).
Automatic user creation is enabled by default for backwards compatibility. It can be disabled when user provisioning should remain manual.
A closer look.
Frequently asked questions.
What header is the JWT retrieved from?
By default the plugin looks for the JWT in the Authorization header as follows:
Authorization: Bearer <JWT Here>
However the token may be retrieved from a configurable HTTP header, for example to integrate with Cloudflare Access, which was the original target for this plugin, you would configure the use of the Cf-Access-Jwt-Assertion header.
What claims should the JWT contain?
The JWT must contain at least an email claim and may also contain a role claim:
{ "iss": "example.com", "aud": "example-audience-id", "email": "admin@example.com", "iat": 1356999524, "nbf": 1357000000, "role": "admin" }
The aud and iss claims are only required when a JWT Audience and/or Issuer value has been configured in the plugin settings, however as they are standard JWT claims it is recommended to set these options to verify those claims exist and are valid.