Guide to Configure Single Sign-On (SSO) between Azure B2C as IDP and Moodle as SP


SAML Single Sign-On (SSO) for your Moodle site can be achieved using our miniOrange SAML SSO plugin. Our plugin is compatible with all the SAML compliant Identity providers. Here we will go through a step-by-step guide to configure Single Sign-On (SSO) between Azure B2C as Identity Provider (IdP) and Moodle as Service Provider (SP).

miniorange img Pre-requisites : Download And Installation

To configure Azure B2C as IdP with Moodle, you will need to install the miniOrange SAML 2.0 SSO plugin:

miniOrange SAML 2.0 SSO

SSO Single Sign On to Moodle with Azure, Azure B2C, Okta, ADFS, Keycloak, Onelogin, Gsuite, Shibboleth & many SAML IdPs [24/7 SUPPORT]

Tested with 4.0.1

Steps to configure Azure B2C Single Sign-On (SSO) Login into moodle (WP)

1. Setup Azure B2C as IdP (Identity Provider)

Follow the steps below to configure Azure B2C as an Identity Provider

miniorange img Configure Azure B2C as IdP
  • In the moodle SAML SP SSO plugin, navigate to Service Provider Metadata tab. Here, you can find the SP metadata such as SP Entity ID and ACS ( AssertionConsumerService ) URL which are required to configure Azure B2C as the Identity Provider.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - initiated sso

2. Register Azure B2C Applications

miniorange img Register the Identity Experience Framework application
  • Login into Azure B2C Portal
  • From the Azure AD B2C tenant, select App registrations, and then select New registration.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Identity Experience FrameWork
  • For Name, enter IdentityExperienceFramework.
  • Under Supported account types, select Accounts in this organizational directory only.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Register an Application
  • Under Redirect URI, select Web, and then enter https://your-tenant-name.b2clogin.com/your-tenant-name.onmicrosoft.com, where your-tenant-name is your Azure AD B2C tenant domain name.
  • NOTE:

    In the following step if the 'Permissions' section is not visible then it might be the reason that you don't have an active AzureAD B2C subscription for that tenant. You can find the details regarding the AzureAD B2C subscription here and you can create a new tenant by following the steps here.


  • Under Permissions, select the Grant admin consent to openid and offline_access permissions check box.
  • Select Register.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Redirect URL
  • Record the Application (client) ID for use in a later step.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Application Client ID
miniorange img Register the Identity Experience Framework application
  • Under Manage, select Expose an API.
  • Select Add a scope, then select Save and continue to accept the default application ID URI.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Expose an api
  • Enter the following values to create a scope that allows custom policy execution in your Azure AD B2C tenant:
    1. Scope name: user_impersonation
    2. Admin consent display name: Access IdentityExperience Framework
    3. Admin consent description: Allow the application to access IdentityExperience Framework on behalf of the signed-in user.
  • Select Add scope
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - custom scopes
miniorange img Register the ProxyIdentityExperienceFramework application
  • Select App registrations, and then select New registration.
  • For Name, enter ProxyIdentityExperienceFramework.
  • Under Supported account types, select Accounts in this organizational directory only.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Original Directory
  • Under Redirect URI, use the drop-down to select Public client/native (mobile & desktop).
  • For Redirect URI, enter myapp://auth.
  • Under Permissions, select the Grant admin consent to openid and offline_access permissions check box.
  • Select Register.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Register
  • Record the Application (client) ID for use in a later step.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle -  application proxy
miniorange img Next, specify that the application should be treated as a public client
  • Under Manage, select Authentication.
  • Under Advanced settings, enable Allow public client flows (select Yes).
  • Select Save.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - proxy authentication
miniorange img Now, grant permissions to the API scope you exposed earlier in the IdentityExperienceFramework registration
  • Under Manage, select API permissions.
  • Under Configured permissions, select Add a permission.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - authentication
  • Select the My APIs tab, then select the IdentityExperienceFramework application.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - API permissions
  • Under Permission, select the user_impersonation scope that you defined earlier.
  • Select Add permissions. As directed, wait a few minutes before proceeding to the next step.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - My APIs
  • Select Grant admin consent for (your tenant name).
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Grant Admin
  • Select your currently signed-in administrator account, or sign in with an account in your Azure AD B2C tenant that's been assigned at least the Cloud application administrator role.
  • Select Yes.
  • Select Refresh, and then verify that "Granted for ..." appears under Status for the scopes - offline_access, openid and user_impersonation. It might take a few minutes for the permissions to propagate.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - B2C,Status og admin access
miniorange img Register the moodle Application
  • Select App registrations, and then select New registration.
  • Enter a Name for the application such as: moodle.
  • Under Supported account types, select Accounts in any organizational directory or any identity provider. For authenticating users with Azure AD B2C.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Supported account types
  • Under Redirect URI, select Web, and then enter the ACS URL from the Service Provider Metadata tab of the miniOrange SAML plugin.
  • Select Register.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - app Register
  • Under Manage, click on Expose an API.
  • Click on Set for the Application ID URI and then click on Save, accepting the default value.
  • SAML Single Sign-On (SSO) using Azure B2C as Identity Provider (IdP),for SAML 2.0 Azure B2C,WP-app Expose a sso login
  • Once saved, copy the Application ID URI and navigate to the Service Provider Metadata tab of the plugin.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - custom login page
  • Paste the copied value under the SP Entity ID / Issuer field provided in this tab.
  • Click on Save.

3. Generate SSO Policies

  • From our Azure B2C portal, navigate to the Overview section of your B2C tenant and record your tenant name.
    NOTE: If your B2C domain is b2ctest.onmicrosoft.com, then your tenant name is b2ctest.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - B2C tenant ID Reco
  • Enter your Azure B2C tenant name below, along with the application ID for IdentityExperienceFramework and
    ProxyIdentityExperienceFramework apps as registered in the above steps.

  • Azure B2C tenant Name:
    IdentityExperienceFramework app ID:
    ProxyIdentityExperienceFramework app ID:


  • Click on the Generate Azure B2C Policies button to download the SSO policies.
  • Extract the downloaded zip file. It contains the policy files and certificate (.pfx), which you will require in the following steps.

4. Setup Certificates

NOTE:

In the following step if the 'Identity Experience Framework' is not clickable then it might be the reason that you don't have an active Azure AD B2C subscription for that tenant. You can find the details regarding the Azure AD B2C subscription here and you can create a new tenant by following the steps here.

miniorange img Upload the Certificate
  • Sign in to the Azure portal and browse to your Azure AD B2C tenant.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - framework
  • Under Policies, select Identity Experience Framework and then Policy keys.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Policy keys
  • Select Add, and then select Options > Upload
  • Enter the Name as SamlIdpCert. The prefix B2C_1A_ is automatically added to the name of your key.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Create a Key
  • Using the upload file control, upload your certificate that was generated in the above steps along with the SSO policies (tenantname-cert.pfx).
  • Enter the certificate's password as your tenant name and click on Create. For example, if your tenant name is xyzb2c.onmicrosoft.com, enter the password as xyzb2c
  • You should be able to see a new policy key with the name B2C_1A_SamlIdpCert.
miniorange img Create the signing key
  • On the overview page of your Azure AD B2C tenant, under Policies, select Identity Experience Framework.
  • Select Policy Keys and then select Add.
  • For Options, choose Generate.
  • In Name, enter TokenSigningKeyContainer.
  • For Key type, select RSA.
  • For Key usage, select Signature.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Create the signing key
  • Select Create.
miniorange img Create the encryption key
  • On the overview page of your Azure AD B2C tenant, under Policies, select Identity Experience Framework.
  • Select Policy Keys and then select Add.
  • For Options, choose Generate.
  • In Name, enter TokenEncryptionKeyContainer.
  • For Key type, select RSA.
  • For Key usage, select Encryption.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Create the encryption key
  • Select Create.

5. Upload the Policies

  • Select the Identity Experience Framework menu item in your B2C tenant in the Azure portal.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - Upload the Policies
  • Select Upload custom policy.
  • Azure B2C moodle SSO - Azure Single Sign-On(SSO) Login in moodle - identity experience framework
  • As per the following order, upload the policy files downloaded in the above steps:
    • TrustFrameworkBase.xml
    • TrustFrameworkExtensions.xml
    • SignUpOrSignin.xml
    • ProfileEdit.xml
    • PasswordReset.xml
    • SignUpOrSigninSAML.xml
  • As you upload the files, Azure adds the prefix B2C_1A_ to each.

You have successfully configured Azure B2C as SAML IdP (Identity Provider) for achieving moodle Azure B2C Single Sign-On (SSO) Login, ensuring secure login into moodle (WP) Site.

6. Configure the plugin

  • Navigate to the Service Provider Setup tab of the plugin and click on the Upload IDP Metadata button.
    • Provide any IDP Name. For example, AzureB2C
    • Enter the Metadata URL as
      https://tenant-name.b2clogin.com/tenant-name.onmicrosoft.com/B2C_1A_signup_signin_saml/Samlp/metadata
    • (NOTE :You will need to replace the tenant-name in above URl with Azure B2C tenant name)

    • Click on the Fetch Metadata button.
SAML Single Sign-On (SSO) using Azure B2C as Identity Provider (IdP),for SAML 2.0 Azure B2C,sp initiated sso

Step 7: Configuring Moodle site as Service Provider

We will go through the steps to setup Moodle as a Service Provider. Here, we will be adding the IdP metadata to configure the plugin.




In the miniOrange SAML SSO plugin, go to the Service Provider Setup tab of the plugin. There are two ways to configure the plugin:

A. By uploading IDP metadata:

  • Click on the Upload IDP metadata button.
  • Enter the Identity Provider Name.
  • You can copy and paste the IdP metadata XML file and click on the Upload Metadata button or use a metadata URL and click on Fetch Metadata.
  • wordpress saml upload metadata

B.Manual Configuration:

  • Provide the required settings (i.e. Identity Provider Name, IdP Entity ID or Issuer, SAML Login URL, X.509 Certificate) as provided by your Identity Provider.
  • Click on the Save button to save your configuration.
  • wordpress saml upload metadata

Step 3: Attribute Mapping

  • When the user performs SSO, the NameID value is sent by the Identity Provider. This value is unique for every user.
  • To assign by which attribute value the user should authenticate or create, select Email (default) or Username in Login/Create Moodle account by:
  • For the plugin to access these attributes, assign the values for Email and Username as 'NameID' (without quotes).
  • Click on the Save button to save your configuration.
  • wordpress saml attribute mapping

Step 4: Role Mapping

  • In the free plugin, you can choose a default role that will be assigned to all the non-admin users when they perform SSO. [NOTE: Roles will be assigned to new users created by SSO. Existing Moodle users’ roles will not be affected.]
  • Go to the Attribute/Role Mapping tab and navigate to the Role Mapping section.
  • Select the Default Role and click on the Save button to save your configuration.
  • wordpress saml role mapping

Step 5: SSO Settings

  • In the plugin, you can add a login widget to enable SP-Initiated SSO on your site.
  • Go to the Plugins >> Authentication >> Manage authentication.
  • Click on the to enable the plugin visibility.
  • Click on the ⬆ to set plugin preference.
  • wordpress saml role mapping


In the miniOrange SAML SSO plugin, go to the Service Provider Setup tab of the plugin. There are two ways to configure the plugin:

A. By uploading IDP metadata:

  • Click on Upload IDP metadata button.
  • Enter the Identity Provider Name
  • You can copy and past IdP metadata XML file and click on Upload Metadata button or use a metadata URL and click on Fetch Metadata.
  • wordpress saml upload metadata

B.Manual Configuration:

  • Provide the required settings (i.e. Identity Provider Name, IdP Entity ID or Issuer, SAML Login URL, X.509 Certificate) as provided by your Identity Provider.
  • Click on the Save button to save your configuration.
  • wordpress saml upload metadata

Step 3: Attribute Mapping

  • When the user performs SSO, the NameID value is sent by the Identity Provider. This value is unique for every user.
  • To assign by which attribute value user should authenticate or create select Email or Username in Login/Create Moodle account by:
  • For the plugin to access these attribute assign the Email and Username attribute.
  • Addtionally user attributes can be mapped (such as Firstname and Lastname).
  • Click on the Save button to save your configuration.
  • wordpress saml attribute mapping

Step 4: Custom Attribute Mapping:

  • This feature allows you to map custom attribute sent by the IDP to the Moodle attributes.
  • You can add multiple attributes by click on "+" button.
  • Click on the Save button to save your configurations.
  • wordpress saml custom attribute mapping

Step 5: Role Mapping

  • This feature allows you to assign and manage roles of the users when they perform SSO. Along with the default Moodle roles, this is compatible with any custom roles as well.
  • Group/Role attribute will provide a mapping for the field name which contains role-related information sent by the IDP and will be used for Role Mapping.
  • Navigate to role mapping section and provide the mappings for the respective roles.
  • For example, If you have a user whose Group/Role attribute value is idp-teacher and you want to assign it to the teacher group then, just provide idp-teacher in the Teacher: field of Role mapping section.
  • Click on the Save button to save your configurations.
  • wordpress saml role mapping

Step 6: SSO settings

  • In the plugin you can add a login widget to enable SP-Initiated SSO on your site.
  • Click on Click here link which will redirect to the Manage authentication menu
  • wordpress saml role mapping
  • Click on the to enable the plugin visibility.
  • Click on the ⬆ to set plugin preference.
  • wordpress saml role mapping
  • To enable auto-redirect from Moodle login page to WordPress site .
  • Click on the Enable Auto-redirect to IDP from Moodle login page.
  • Note down Backdoor URL it will be useful when SSO fails.
  • Click on the Save button to save your configuration.
  • moodle saml role mapping


If you are looking for anything which you cannot find, please drop us an email on samlsupport@xecurify.com

Hello there!

Need Help? We are right here!

support
Contact miniOrange Support
success

Thanks for your inquiry.

If you dont hear from us within 24 hours, please feel free to send a follow up email to info@xecurify.com