WP Manifestindependent plugin directory
manifest / users / entra-id-sso

Entra ID SSO

WordPress plugin: Microsoft Entra ID single sign-on (OIDC with PKCE), user provisioning and app-role to WordPress-role mapping.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/martinarafat/entra-id-sso/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Entra ID SSO for WordPress

Sign in to WordPress with a Microsoft work account (Entra ID). Accounts are created on first sign-in and the WordPress role comes from Entra app roles or groups.

How the sign-in works

  1. The user clicks Sign in with Microsoft on the login page.
  2. The plugin creates a one-time state, a nonce and a PKCE code verifier, stores them server-side for 10 minutes, and ties the state to the browser with an HttpOnly cookie.
  3. The user is sent to Entra ID (authorization code flow with PKCE, S256).
  4. Entra sends the user back to wp-login.php with a code. The state must exist, must not have been used, and must match the browser cookie.
  5. The code is exchanged for tokens using the client secret and the PKCE verifier.
  6. The ID token is checked before anything else happens:
    • RS256 signature against the tenant's signing keys (cached for a day, re-downloaded once if the key ID is new, since Microsoft rotates keys)
    • issuer, audience, tenant ID, expiry, not-before, issued-at, and nonce
  7. The user is matched by Entra object ID (oid), then by email if linking is on, otherwise a new account is created.
  8. The role is set from the role map, the user is logged in, and the attempt is written to the sign-in log.

If any check fails, the sign-in stops with a message and the attempt is logged.

Entra ID setup

  1. Azure portal > Microsoft Entra ID > App registrations > New registration
    • Supported account types: this organizational directory only
    • Redirect URI: platform Web, and paste the URL shown on Settings > Microsoft SSO (it's your wp-login.php URL). Entra requires HTTPS, except for localhost.
  2. From the app Overview, copy the Application (client) ID and Directory (tenant) ID.
  3. Certificates & secrets > New client secret, and copy the value.
  4. For role mapping, pick one:
    • App roles (recommended): App roles > create roles such as Intranet.Editor, then assign users or groups in Enterprise applications > your app > Users and groups. They arrive in the roles claim.
    • Security groups: Token configuration > Add groups claim > Security groups. Group object IDs arrive in the groups claim.

WordPress setup

  1. Activate the plugin and open Settings > Microsoft SSO.

  2. Paste the tenant ID and client ID.

  3. Add the secret. For production, put it in wp-config.php instead of the database:

    define( 'ENTRA_SSO_CLIENT_SECRET', 'your-secret' );

    It can also come from an environment variable with the same name, which is how it would be loaded from Azure Key Vault on App Service.

  4. Add role rules, one per line. The first match wins:

    Intranet.Admin = administrator
    Intranet.Editor = editor
    3f2a9c1e-0000-0000-0000-000000000000 = author

Options

  • Create accounts on first sign-in, with a default role (administrator is never allowed as the default)
  • Link existing accounts by email, so current users keep their content
  • Private site: visitors who aren't signed in are sent straight to Microsoft sign-in
  • Sign out of Microsoft too when logging out of WordPress

Notes

  • MFA is enforced in Entra with Conditional Access, so the plugin doesn't need to handle it.
  • Groups overage: if a user is in more than about 200 groups, Entra leaves the list out of the token. The plugin detects this and logs it. App roles avoid the problem.
  • Lockout safety: a role rule never demotes an administrator, and the normal WordPress password form stays available for break-glass access.
  • Uninstalling removes the settings and log, but keeps user accounts.

Requirements

WordPress 6.4+, PHP 7.4+ with OpenSSL, HTTPS.