Configure the Magento OAuth & OpenID Connect Single Sign-On (SSO) extension with Azure B2C Single Sign-On (SSO). Use Microsoft Azure B2C as an OAuth and OpenID Connect provider to provide safe login into Magento. With Azure B2C Single Sign-On (SSO), your users may log in and access your Magento site by authenticating with their Azure B2C identity provider. You can also use various IDPs, such as Azure AD, Office 365, and other bespoke providers, to configure the extension. It has powerful Single Sign-On (SSO) features like user profile attribute mapping and role mapping, among others. We'll go over how to set up Single Sign-On (SSO) for user authentication between Magento and Azure B2C in this guide.
To know more about other features we provide in Magento OAuth Single Sign-On ( OAuth & OpenID Connect Client ) extension, you can click here.
Pre-requisites : Download And Installation
Installation using Composer:
php bin/magento setup:di:compile
php bin/magento setup:upgrade
Manual Installation:
- Download the miniOrange OAuth OpenID Connect Single Sign-On extension zip from here.
- Unzip all contents of the zip inside the MiniOrange/OAuth directory.
{Root Directory of Magento} app code MiniOrange OAuth
Run the following commands on command prompt to enable the extension.
php bin/magento setup:di:compile
php bin/magento setup:upgrade
Magento OAuth OpenID Connect SSO extension allows login (Single Sign-On) into Magento with your Azure AD, Azure B2C, AWS Cognito, WSO2, Okta, LinkedIn, Google, Facebook, Slack, Discord or other custom OAuth 2.0 providers [24/7 SUPPORT]
Steps to configure Azure AD B2C OAuth & OpenID Single Sign-On (SSO) Login into Magento
1. Setup Azure Active Directory B2C as OAuth Provider
Follow the steps below to configure Azure AD B2C as OAuth Provider
Configure Azure AD B2C as OAuth Provider
<- Sign in to Azure portal.
- Go to Home and in the Azure services, select Azure AD B2C.
- Please make sure you are in the Azure AD B2C directory with an active subscription and if not, you can switch to the correct directory.
- In the Essentials tab, you will find the Azure B2C domain name, keep it handy, you will need it later for configuring the Azure B2C tenant name under Magento OAuth SSO extension.
What is Tenant Name?
You will need to copy the highlighted domain name portion only as shown in the below screenshot in order to configure the tenant name in the Magento OAuth SSO extension.
Eg. If your domain name is 'exampledomain.onmicrosoft.com', then your tenant name will be 'exampledomain'.
- Now, click on App registrations and then click on the New registration option to create a new Azure b2c application.
- 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 (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)’
- 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.
- After successful application creation, you will be redirected to the newly created application’s overview page. If not, you can go to the app registrations and search the name of your application and you will find your application in the list.
- Copy your Application ID and keep it handy, you will need it later for configuring the Client ID under Magento OAuth SSO extension.
- Now, click on Certificates and secrets and then click on New client secret to generate a client secret. Enter a description and click on the Add button.
- Copy the secret value from certificates & secrets page and keep it handy, you will need it later for configuring the Client Secret under Magento OAuth Client extension.
Step 1.1: Add Users in your B2C application
- In home page, go to the Users tab in the left corner
- Click on New user in the users page
- Select Create Azure AD B2C user. Then, scroll down and click on Email from sign in method and set your password and click create to save the user details to perform test configuration.
Step 1.2: How to create & add Azure B2C Policy
- Go to User Flows tab and then click on New user flow.
- Select a User flow type Sign up and Sign in then click on Create button.
- Fill all the information e.g. Name, Identity providers, etc. then click on Create button.
- Copy the Policy name this value whenever you need to enter Azure B2C Policy in miniOrange OAuth Client extension.
Step 1.3: Add user claims to your application
- Go to user flows under policies in the left corner. Select the configured policy.
- Select Application claims in settings
- Select the desired attributes to be displayed on the test configuration and save it.
Step 1.4: Configure ID-Token Claims in Azure B2C [Premium]
- Go to your application in Azure Active Directory 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 SSO (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.
You've successfully configured Azure AD (Active Directory) B2C as an OAuth Provider for Magento user integration using Azure AD Single Sign-On (SSO)
2. Configuring Magento 2 as OAuth Client
3. Sign-In Settings
- Navigate to Sign-in Settings tab. Here you find the option the enable the login link on Admin*/Customer Login Page (*Admin SSO is available in the premium versions)
- If you want to initate SSO from any page you can also use the SSO link provided in the extension.
- The Premium extension also provides you the the feature to auto redirect your user to the IdP Login Page if the user is not already logged in.
Attribute / Custom Attribute Mapping (Optional). *This is Premium feature.
1.1: Attribute Mapping (Optional). *This is Premium feature.
- You can map attributes in the Attribute Mapping tab. Only username and email are allowed to be mapped in free version of the extension. However, in the premium version of the extension, you can map various attributes coming from your OAuth Provider to the attributes present in your Magento site.
1.2: Custom Attribute Mapping (Optional). *This is Premium feature.
- Enter your table name in Table field.
- Enter attribute name as your column name (in the respective table)
- Click on Add button for adding custom magento attribute and map the respective field with the attribute receiving from your identity provider
- Click on save button for saving the configuration.
- You can also delete the configuration by entering the name in attribute name field and then click on delete button.
Role Mapping (Optional). *This is Premium feature.
- You can specify a default role in the free extension that will be allocated to all non-admin users when they conduct SSO.
- Go to Attribute/Role mapping tab and navigate to Role Mapping section.
- Select the Default Role and click on the Save button.
By configuring Azure AD B2C as an OAuth Provider and Magento as an OAuth Client using our Magento OAuth Client extension, you have successfully installed Magento Azure AD (Active Directory) B2C Single Sign-On (SSO). Within minutes, you'll be able to provide safe access to your Magento site utilising Azure AD B2C login credentials thanks to this solution.p>
Additional Resources