Configure Azure AD Single Sign-On (SSO) for WordPress using OAuth | Azure AD SSO
Overview
WordPress Azure AD SSO uses OAuth Authorization flow to provide users secure access to WordPress sites. With our WordPress OAuth Single Sign-On (SSO) plugin, Azure AD acts as the OpenID Connect and OAuth provider, ensuring secure login for WordPress websites. The integration of WordPress Azure AD simplifies and secures the login process using Azure AD SSO. This solution allows employees to access their WordPress sites with a single click using their Azure Active Directory (Azure AD) credentials, completely removing the need to store, remember, and reset multiple passwords. In addition to offering Azure AD Single Sign-On (SSO) functionality, the plugin also provides advanced SSO features like user profile attribute mapping, role mapping, and Azure multi-tenant login and providing site access based on organization email domains. For a detailed overview of the features, check out the WordPress OAuth Single Sign-On (SSO) plugin. You can follow the below steps to setup Azure Active Directory (Azure AD) SSO with WordPress.
WordPress Azure integration provides functionality to manage all the user
operations from your WordPress site. [Sync user profile from WordPress to Microsoft Entra ID (Azure AD)]
Pre-requisites : Download And Installation
- Log into your WordPress instance as an admin.
- Go to the WordPress Dashboard -> Plugins and click on Add New.
- Search for a WordPress OAuth Single Sign-On (SSO) plugin and click on Install Now.
- Once installed click on Activate.
Configuration Steps
Step 1: Setup Microsoft Entra ID (Azure AD) as OAuth Provider
- Sign in to Microsoft Entra ID (Azure AD) portal.
- Select Microsoft Entra ID (Azure AD).
- In the left-hand navigation panel, click the App registrations service, and click New registration.
- Configure the following options to create a new application.
- Enter a name for your application under the Name text field.
- In supported account types, select 3rd option ‘Accounts in any organizational directory (for authenticating user with user flows).
- In the Redirect URI section, select the Web application and enter the Callback URL from the miniOrange OAuth Client plugin (Configure OAuth tab) and save it under the Redirect URL textbox.
- Click on the Register button to create your application.
- Microsoft Entra ID (Azure AD) assigns a unique Application ID to your application. The Application ID is your Client ID and the Directory ID is your Tenant ID, keep these values handy as you will need them to configure the miniOrange OAuth Client plugin.
- Go to Certificates and Secrets from the left navigaton panel and click on New Client Secret. Enter description and expiration time and click on ADD option.
- Copy the secret key "value" and keep the value handy it will be required later to configure Client Secret under the miniOrange OAuth Client Plugin.
Note: The client secret for your developer application will expire in 180 days. To ensure continued functionality, you will need to generate a new client secret before the expiration and update it in the OAuth Single Sign-On plugin.
In conclusion , by successfully configuring Azure AD as OAuth Provider, you have enabled WordPress Azure AD SSO Login and authorization for your end users into WordPress.
Step 2: Setup WordPress as OAuth Client
- Free
- Premium
Step 3: User Attribute Mapping
- User Attribute Mapping is mandatory for enabling users to successfully login into WordPress. We will be setting up user profile attributes for WordPress using below settings.
- Go to Configure OAuth tab. Scroll down and click on Test Configuration.
- You will see all the values returned by your OAuth Provider to WordPress in a table. If you don't see value for First Name, Last Name, Email or Username, make the required settings in your OAuth Provider to return this information.
- Once you see all the values in Test Configuration, go to Attribute / Role Mapping tab, you will get the list of attributes in a Username dropdown.
Finding user attributes:
Step 4: Microsoft Entra ID (Azure AD) Profile/Groups Mapping
- Go to Application → Select the application where you want to configure the group mapping for WordPress Azure AD SSO. Now, Go to the API Permissions tab.
- Click on the Add permission button, and then Microsoft Graph API -> Delegated Permissions and select openid, Profile scope and click on the Add Permissions button.
- Click on the Grant consent for Demo button.
- Go to Manifest tab and find groupMembershipClaims and changes it’s value to "All" and click on the save button.
- Now you would be able to get the group's value in the Test configuration window.
- You can follow the role mapping section to map the groups to WordPress users in order to enable Azure AD SSO.
4.1 WordPress OAuth - WordPress Groups/Profile Mapping [Premium]
- Go to the Attribute Mapping section in the plugin and map the Attribute Names from the Test Configuration table. Make sure Enable Role Mapping option is enabled and click on the Save Settings button. (Refer to the screenshot)
- Scroll down and go to the Role Mapping section, you need to map Group Attribute Name. Select the
attribute name
from the list of attributes that return the groups from the test configuration table of Azure Active Directory
(Azure AD).
Eg:Groups - Assign the WordPress role to the Provider Groups: Based on the Azure Active Directory (Azure AD)
application,
you can allocate the WordPress role to Azure AD Groups. Add the Azure AD group's value under Group Attribute
Value and assign the required WordPress role in front of it under WordPress Role.
For example, in the below image. Group value has been assigned the role of Subscriber. - After saving the mapping, the Azure Active Directory group will be allocated the WordPress Subscriber role
following the implementation of Azure AD SSO.
Example: As per the given example, a User with group value will be added as a administrator.
4.2 WordPress OAuth - Microsoft Entra ID (Azure AD) Claim Mapping [Premium]
- Go to your application in Azure Active Directory (Azure AD) and select Token configuration from the left menu.
- Click on Add optional claim and then select ID from the right section.
- Now choose all the attributes you want to fetch while performing Single Sign-On (SSO) with Azure Active Directory (e.g family_name, given_name, etc) and click on Add button.
- You might see a popup to Turn on the Microsoft Graph profile permission (required for claims to appear in token), enable it, and click on Add button.
Step 5: Steps to fetch additional user attributes from Microsoft Entra ID (Azure AD)
- Sign into Microsoft Entra ID (Azure AD) Portal.
- Select Microsoft Entra ID (Azure AD).
- In the left-hand navigation panel, click the Enterprise applications.
- Select your Azure Enterprise Application.
- Then select the Single sign-on (SSO) option in the left-hand menu and open the Attributes & Claims section.
- Click on Add new claim.
- Then configure the required fields as below:
- Now navigate to App registrations, select your application, and then go to the Manifest tab on the left and set "acceptMappedClaims": true
- After following the above steps, you can create multiple claims as per your requirements.
- Please try to perform the Test Configuration in the WordPress OAuth SSO plugin. You'll get a new attribute as shown below:
Name : | As per your choice (this will be your Attribute name) |
Source: | Attribute |
Source attribute: | For eg: search for user.department in the dropdown |
Step 6: Sign In Settings
- WordPress 5.7 and below
- WordPress 5.8
- WordPress 5.9 and above
Step 7: Scope & Endpoints
Scope: | openid |
Authorize Endpoint: | https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize |
Access Token Endpoint: | https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token |
Get User Info Endpoint: | https://login.windows.net/<tenant-id>/openid/userinfo |
Custom redirect URL after logout:[optional] | https://login.microsoftonline.com/<tenant-id>/oauth2/logout?post_logout_redirect_uri=<your URL> |
Scope: | openid |
Authorize Endpoint: | https://login.microsoftonline.com/common/oauth2/v2.0/authorize |
Access Token Endpoint: | https://login.microsoftonline.com/common/oauth2/v2.0/token |
Get User Info Endpoint: | https://login.windows.net/common/openid/userinfo |
Custom redirect URL after logout:[optional] | https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=<your URL> |
Troubleshooting Errors
More Troubleshooting Errors ➔invalid_request
To fix this issue while configuring Azure AD OAuth Single Sign-On (SSO), please configure the correct Authorization Endpoint in the plugin. You can confirm the correct format of the endpoint from here.
invalid_client
If you face this issue while performing Azure AD Single SIgn-On (SSO) with OAuth, please configure the correct Client Secret in the plugin. You can refer to this step to configure correct client secret in the setup guide.
invalid_resource
To fix this issue while configuring Azure AD OAuth Single Sign-On (SSO), please configure the 'common' endpoints in the plugin or add user in the tenant . You can refer to this setup guide to configure the common endpoints.
AADSTS50011
Please configure the correct Redirect URL in the Microsoft Entra ID (Azure AD) Developer application from the plugin If you face this issue while configuring Azure AD OAuth Single Sign-On (SSO). You can refer to this steps in the setup guide.
FAQs
How to achieve Microsoft Entra ID (Azure AD) SSO with guest users outside of your Azure directory?
In WordPress OAuth Client SSO plugin, Select your Configured Microsoft Entra ID (Azure AD) application and in the field of Azure AD Tenant, replace the current tenant id with ‘common’ as shown in the below screenshot. Now users from any Azure directory will be able to perform Azure AD OAuth SSO and also users with personal Microsoft accounts can login. read more
How to configure Microsoft Entra ID (Azure AD) password grant with WordPress OAuth Client SSO plugin?
Microsoft Entra ID (Azure AD) recently released OAuth 2.0 endpoints. You need to replace the token endpoint with the one below. You also need to change the grant type to password grant in the dropdown and replace the tenant ID with your Microsoft Entra ID (Azure AD) tenant ID. (Refer to the below image) Read more
Microsoft Entra ID (Azure AD) SSO isn’t working due to admin permission issues from the Microsoft Entra ID (Azure AD) end.
Sign in to your Microsoft Entra ID (Azure AD) portal and select your Microsoft Entra ID (Azure AD) where you have Azure AD OAuth SSO. Select Enterprise applications. Read more