Hi, I'm Marc. I build Faable, a platform with its own OAuth 2.0 / OpenID Connect server, and we just published a WordPress plugin that makes a site sign in through it. The plugin is free and in the WordPress.org directory, but this post is not about installing it. It's about the decisions that turned out to matter more than the OIDC flow itself, because they apply to any "Log in with X" plugin you write or choose.
The flow is the easy part: authorization code with PKCE (S256), the callback at /wp-login.php?faable-auth=callback, a user created on first login with no usable local password. Everything below is what comes after.
1. "SSO" that leaves the password door open isn't SSO
A plugin that adds a button next to the username and password form adds a second way in, not a replacement. WordPress has more doors than the form:
- password logins and password resets
- user registration
- XML-RPC authentication
- Application Passwords on the REST API
Once the site is connected, we turn all of them off. Until it is connected, the native login stays on, so the administrator who installs the plugin can still get in to connect it.
2. Re-read roles on every login, and fail closed
If roles are copied once at account creation, removing someone's access in your identity provider does nothing to the WordPress site. So the WordPress role is recomputed on every login from the user's roles in the identity provider, through a map:
administrator = administrator
editor = editor
staff = editor
Three rules keep it honest:
- If several roles map, the most privileged one wins.
- A user whose roles map to nothing gets no account. If they already had one, its role is removed and its sessions are ended.
- If the roles cannot be read (network error, missing permission), the login is refused. A plugin that guesses here, or falls back to "subscriber", turns an outage into a privilege bug.
3. Link existing accounts by verified email only
A site that already has users needs to match them to identity provider accounts, and email is the obvious key. It's also an account takeover if the email isn't verified: anyone can sign up at the provider with admin@yoursite.com and arrive as your administrator.
The order we use:
- The WordPress user already linked to that identity.
- A not-yet-linked WordPress user with the same email, only if the provider says the email is verified.
- Otherwise, a new user.
If the email belongs to an existing user but isn't verified, the login is refused and the user is asked to verify it first.
4. Headless front-ends need a replacement for Application Passwords
Turning off Application Passwords (point 1) breaks every Next.js front-end or build job that reads the REST API with Basic Auth. The replacement is a machine-to-machine token from the same identity provider:
curl https://example.com/wp-json/wp/v2/posts \
-H "Authorization: Bearer <access_token>"
A request is accepted only if the token is signed by your tenant, issued for the configured audience, is a client_credentials token (a token issued to a person is refused), comes from an allowed client, and carries the required scope if you set one. The request then acts as a dedicated WordPress user, so give that user the smallest role that works.
For migrations there is an escape hatch: a list of local service users that keep their Application Passwords on the REST API, and still can't open a wp-admin session.
5. Plan emergency access before you need it
When the identity provider is unreachable, nobody can log in. That has to be solved on day one, not during the outage. Two ways in:
// wp-config.php: brings back the password form and resets, with a warning in the admin
define( 'FAABLE_AUTH_BREAK_GLASS', true );
# a URL that logs in as that user, once, within 10 minutes
wp faable-auth login-link <user>
One detail on the second: opening the link shows a confirmation button instead of logging in straight away. Paste a one-time link in Slack or WhatsApp and the link preview bot opens it before the person does. Without the button, the bot uses it up.
6. Logout is a URL match, not a redirect
Federated logout (ending the identity provider session when you log out of WordPress) is RP-initiated logout: the site sends the browser to the provider with a post_logout_redirect_uri, and the provider only honours it if it matches a registered logout URL exactly. In WordPress that's:
https://example.com/wp-login.php?loggedout=true
Register anything else, even the site's home page, and logout shows an error from the provider. We shipped exactly that bug in our dashboard's setup flow (it registered https://example.com/) and fixed it the same day.
Try it
The plugin: wordpress.org/plugins/faable-auth. The full guide, with every setting and environment variable: faable.com/docs/auth/integrations/wordpress. It works with the Free plan of Faable Auth. WordPress 6.4+, PHP 8.1+, no Multisite yet.
If you've built or audited a WordPress SSO plugin, I'd like to hear what I missed.
Top comments (0)