Name: aad-sso-wordpress
Description: Single Sign-on with Azure Active Directory (for WordPress)
Created: 2014-02-15 11:39:49.0
Updated: 2018-01-07 23:09:29.0
Pushed: 2017-12-20 07:39:45.0
Size: 537
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A WordPress plugin that allows organizations to use their Azure Active Directory user accounts to sign in to WordPress. Organizations with Office 365 already have Azure Active Directory (Azure AD) and can use this plugin for all of their users.
This is a work in progress, please feel free to contact me for help. This plugin is provided as-is, with no guarantees or assurances.
In the typical flow:
wp-admin
). At the sign in page, they are given a link to sign in with their Azure Active Directory organization account (e.g. an Office 365 account).The following instructions will get you started. In this case, we will be configuring the plugin to use the user roles configured in WordPress.
This plugin is not yet registered in the WordPress plugin directory (coming soon!), but you can still install it manually:
git
or with the 'Download ZIP' link on the right.aad-sso-wordpress
folder in your WordPress' plugin folder. Normally, this is <your-blog>/wp-content/plugins
.With these steps, you will register an application with Azure AD. This application identifies your WordPress site with Azure AD.
Sign in to the Azure portal, and ensure you are signed in to the directory which has the users you'd like to allow to sign in. (This will typically be your organization's directory.) You can view which directory you're signed in to (and switch directories if needed) by clicking on your username in the upper right-hand corner.
Navigate to the Azure Active Directory blade, and enter the App registrations section.
Choose New application registration, and provide a name for your app. This will be the name displayed to users when signing in. Leave the default application type (“Web app / API”), provide the URL of your site as the “Sign-on URL”, and click Create. When the app is created, select the newly-registered app from the list.
Under Reply URLs, update the existing reply URL with the format: https://<your blog url>/wp-login.php
, or whichever page your blog uses to sign in users, and click Save. (Note: This page must invoke the authenticate
action.)
Under Required permissions, choose the “Windows Azure Active Directory” API. You will need at minimum delegated permissions to “Sign in and read user profile”. If you wish to map Azure AD groups to WordPress roles, you will also need delegated permission to “Read directory data”. Once you've selected the permissions, click Save.
Important: The “Read directory data” delegated permissions requires a tenant administrator to consent to the application. The tenant administrator can use the Grant Permissions option to grant permissions (i.e. consent) on behalf of all users.
Under Keys, provide a new secret key description and duration, and click Save. After saving, the secret key value will appear. Copy it, as this is the only time it will be available.
Keep a tab open with the app registration page, as you will need to copy some fields when configuring the plugin.
Once the plugin is activated, update your settings from the WordPress admin console under Settings > Azure AD. Basic settings to include are:
The Single Sign-on with Azure AD plugin can be configured to set different WordPress roles based on the user's membership to a set of user-defined groups. This is a great way to control who has access to the blog, and under what role.
This is also configured Settings > Azure AD (from the WordPress admin console). The following fields should be included:
The different fields that can be defined in the settings JSON in Settings > Azure AD are documented in Settings.php. The following may give you an idea of the typical scenarios that may be encountered.
Users are matched by their email address in WordPress, and whichever role they have in WordPress is maintained.
| Setting | Example value | — | — | Display name | Contoso | Client ID | 9054eff5-bfef-4cc5-82fd-8c35534e48f9 | Client Secret | NTY5MmE5YjMwMGY2MWQ0NjU5MzYxNjdjNzE1OGNiZmY= | Reply URL | https://www.example.com/blog/wp-login.php | Field to match to UPN | Email Address
Users are matched by their login names in WordPress and the alias portion of their Azure AD UserPrincipalName. Whichever role they have in WordPress is maintained.
| Setting | Example value | — | — | Display name | Contoso | Client ID | 9054eff5-bfef-4cc5-82fd-8c35534e48f9 | Client Secret | NTY5MmE5YjMwMGY2MWQ0NjU5MzYxNjdjNzE1OGNiZmY= | Reply URL | https://www.example.com/blog/wp-login.php | Field to match to UPN | Login Name | Match on alias of the UPN | Yes
Users are matched by their login names in WordPress, and WordPress roles are dictated by membership to a given Azure AD group. Access is denied if they are not members of any of these groups.
| Setting | Example value | — | — | Display name | Contoso | Client ID | 9054eff5-bfef-4cc5-82fd-8c35534e48f9 | Client Secret | NTY5MmE5YjMwMGY2MWQ0NjU5MzYxNjdjNzE1OGNiZmY= | Reply URL | https://www.example.com/blog/wp-login.php | Field to match to UPN | Login Name | Enable Azure AD group to WP role association | Yes | Default WordPress role if not in Azure AD group | (None, deny access) | WordPress role to Azure AD group map |
Administrator | 5d1915c4-2373-42ba-9796-7c092fa1dfc6 |
Editor | 21c0f87b-4b65-48c1-9231-2f9295ef601c |
Author | f5784693-11e5-4812-87db-8c6e51a18ffd |
Contributor | 780e055f-7e64-4e34-9ff3-012910b7e5ad |
Subscriber | f1be9515-0aeb-458a-8c0a-30a03c1afb67 |
Users are matched by their login names in WordPress, and WordPress roles are dictated by membership to a given Azure AD group. If the user is not a part of any of these groups, they are assigned the Author role.
| Setting | Example value | — | — | Display name | Contoso | Client ID | 9054eff5-bfef-4cc5-82fd-8c35534e48f9 | Client Secret | NTY5MmE5YjMwMGY2MWQ0NjU5MzYxNjdjNzE1OGNiZmY= | Reply URL | https://www.example.com/blog/wp-login.php | Field to match to UPN | Login Name | Enable Azure AD group to WordPress role association | Yes | Default WordPress role if not in Azure AD group | Author | WordPress role to Azure AD group map |
Administrator | 5d1915c4-2373-42ba-9796-7c092fa1dfc6 |
Editor | 21c0f87b-4b65-48c1-9231-2f9295ef601c |
Author | f5784693-11e5-4812-87db-8c6e51a18ffd |
Contributor | 780e055f-7e64-4e34-9ff3-012910b7e5ad |
Subscriber | f1be9515-0aeb-458a-8c0a-30a03c1afb67 |
Users are matched by their email in WordPress, and WordPress roles are dictated by membership to a given Azure AD group. If the user doesn't exist in WordPress yet, they will be auto-provisioned. If the user is not a part of any of these groups, they are assigned the Subscriber role.
| Setting | Example value | — | — | Display name | Contoso | Client ID | 9054eff5-bfef-4cc5-82fd-8c35534e48f9 | Client Secret | NTY5MmE5YjMwMGY2MWQ0NjU5MzYxNjdjNzE1OGNiZmY= | Reply URL | https://www.example.com/blog/wp-login.php | Field to match to UPN | Email Address | Enable auto-provisioning | Yes | Enable Azure AD group to WP role association | Yes | Default WordPress role if not in Azure AD group | Subscriber | WordPress role to Azure AD group map |
Administrator | 5d1915c4-2373-42ba-9796-7c092fa1dfc6 |
Editor | 21c0f87b-4b65-48c1-9231-2f9295ef601c |
Author | f5784693-11e5-4812-87db-8c6e51a18ffd |
Contributor | 780e055f-7e64-4e34-9ff3-012910b7e5ad |
Subscriber | f1be9515-0aeb-458a-8c0a-30a03c1afb67 |
As described above, you can map Azure AD groups to WordPress roles. Users who are members of the Azure AD group will be granted the WordPress role(s) the groups were mapped to.
There are several ways Azure AD groups can be created/managed. Some of them require the group owner/creator to be a tenant administrator, others not necessarily (depending on your organization's policy):
Most of the OpenID Connect endpoints and configuration (e.g. signing keys, etc.) are obtained from the OpenID Connect configuration endpoint. These values are cached for one hour, but can always be forced to re-load by adding aadsso_reload_openid_config=1
to the query string in the login page. (This shouldn't really be needed, but it has shown to be useful during development.)
If you've configured this plugin to automatically redirect to Azure AD for sign-in, but something is misconfigured, you may find yourself locked out of your site's admin dashboard.
To log in to your site without automatically redirecting to Azure AD (thus giving you an opportunity to enter a regular username and password), you can append ?aadsso_no_redirect=please
to the login URL. For example, if your login URL is https://example.com/wp-login.php
, navigating to https://example.com/wp-login.php?aadsso_no_redirect=please
will prevent any automatic redirects.