OAuth Single Sign-On (SSO) For Laravel Using Azure B2C As OAuth provider

OAuth Single Sign-On (SSO) For Laravel Using Azure B2C As OAuth provider


Laravel OAuth Single Sign-On (SSO) plugin gives the ability to enable OAuth Single Sign-On for your laravel applications. Using Single Sign-On you can use only one password to access your laravel application and services. Our plugin is compatible with all the OAuth compliant Identity providers. Here we will go through a step-by-step guide to configure Single Sign-On (SSO) between Laravel and Azure B2C considering Azure B2C as OAuth provider.

Pre-requisites : Download And Installation

  • Open a Command Prompt window and change the working directory to your Laravel app's main directory.
  • Enter the below command.
    composer require miniorange/oauth-laravel-free
  • After successful installation of package, go to your Laravel app in the browser and enter {laravel-application-domain}/ssologin.php?option=oauthredirect in the address bar.
  • The package will start setting up your database for you and then redirect you to the admin registration page.
  • Register or log in with your account by clicking the Register button to configure the plugin.
  • Laravel Single Sign On SSO plugin settings
  • After login, you will see the OAuth provider Settings option, where you will get the Redirect/Callback URL. Keep it handy as it will be required later to configure step 1.
  • Laravel Single Sign On SSO OAuth Client Settings

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

1. Configure Azure B2C as OAuth Provider

  • Sign in to Azure portal.
  • Go to Home and in the Azure services, select Azure B2C B2C.
  • Azure B2C B2C Single Sign-on (SSO) - Select Azure B2C B2C
  • Please make sure you are in the Azure B2C B2C directory with an active subscription and if not, you can switch to the correct directory.
  • Azure B2C B2C Single Sign-on (SSO) - Login Applications
  • 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 Laravel as an OAuth client.

    What is Tenant Name?
    You will need to copy the highlighted domain name portion only in order to configure the tenant name in the Laravel OAuth Client plugin.
    Eg. If your domain name is 'exampledomain.onmicrosoft.com', then your tenant name will be 'exampledomain'.


  • Azure B2C B2C Single Sign-on (SSO) - Generate Key
  • Now, click on App registrations and then click on the New registration option to create a new Azure b2c application.
  • Azure B2C B2C Single Sign-on (SSO) - Login Applications
  • 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 identity provider or organizational directory (for authenticating users 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.
    • Azure B2C B2C Single Sign-on (SSO) - Create
  • 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.
  • Azure B2C B2C Single Sign-on (SSO) - Applications option
  • Copy your Application ID and keep it handy, you will need it later for configuring the Client ID under Laravel as an OAuth Client plugin.
  • Azure B2C B2C Single Sign-on (SSO) - Application ID
  • 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.
  • Azure B2C B2C Single Sign-on (SSO) - Generate Key
  • Copy the secret value from certificates & secrets page and keep it handy, you will need it later for configuring the Client Secret under Laravel as an OAuth Client plugin.
  • Azure B2C B2C Single Sign-on (SSO) - Generate Key

Step 1.1: Add Users in your b2c application

  • In home page, go to the Users tab in the left corner
  • Azure B2C B2C Single Sign-on (SSO) - user flow
  • Click on New user in the users page
  • Azure B2C B2C Single Sign-on (SSO) - user flow
  • Select Create Azure B2C 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.
  • Azure B2C B2C Single Sign-on (SSO) - user flow Azure B2C B2C Single Sign-on (SSO) - user flow

2. Configure Laravel OAuth plugin as OAuth Client

  • Go to the miniOrange Laravel OAuth SSO plugin and click on Choose you OAuth provider.
  • Laravel Single Sign On SSO select app
  • Enter the Client ID, Client Secret, and other required details. Click on Save Settings button.
  • Laravel Single Sign On SSO save settings

3. SSO Options

  • You can also use a link to login via your OAuth/OpenID provider.
  • This link is in the format:
    {laravel-application-domain}/ssologin.php?option=oauthredirect

In this Guide, you have successfully configured Azure B2C OAuth Single Sign-On (Azure B2C SSO Login) choosing Azure B2C as OAuth provider and Laravel as OAuth Client using miniOrange plugin-OAuth Single Sign On – SSO Login. This solution ensures that you are ready to roll out secure access to your Laravel site using Azure B2C login credentials within minutes.

Additional Resources

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