PHPackages                             wika-group/magento2-azure-ad-b2c-sso - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. wika-group/magento2-azure-ad-b2c-sso

ActiveMagento2-module[Authentication &amp; Authorization](/categories/authentication)

wika-group/magento2-azure-ad-b2c-sso
====================================

Module to add support for a login via Azure B2C

1.12.0(1y ago)11192MITPHPPHP ^8.2

Since May 21Pushed 1y ago2 watchersCompare

[ Source](https://github.com/WIKA-Group/magento2-azure-ad-b2c-sso)[ Packagist](https://packagist.org/packages/wika-group/magento2-azure-ad-b2c-sso)[ RSS](/packages/wika-group-magento2-azure-ad-b2c-sso/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (27)Used By (0)

Mage2 Module WIKA Azure B2C
===========================

[](#mage2-module-wika-azure-b2c)

Magento2 Module to add support for a login via Azure B2C.

This module can create a new Magento customer. It only sets the email, firstname and lastname.
If you want to fill other fields or store an address, you can use the events.

> **Important:** Ensure that the email address is delivered in the Azure B2C response.

**Table of contents**

- [Installation](#installation)
- [Updating to latest version](#updating-to-latest-version)
- [Configuration](#configuration)
    - [Autologin after registration in B2C](#autologin-after-registration-in-b2c)
    - [Log out from Azure B2C](#log-out-from-azure-b2c)
- [Call authorize with referer](#call-authorize-with-referer)
- [Events](#events)
    - [customer\_login](#customer_login)
    - [customer\_logout\_after](#customer_logout_after)
    - [azure\_b2c\_sso\_\[create|update\]\_customer\_after](#azure_b2c_sso_createupdate_customer_after)

Installation
------------

[](#installation)

This Magento2 module can be installed using composer:
`> composer require wika-group/magento2-azure-ad-b2c-sso`

To remove it from the list of required packages use the following command:
`> composer remove wika-group/magento2-azure-ad-b2c-sso`

Updating to latest version
--------------------------

[](#updating-to-latest-version)

With the following command composer checks all packages in the composer.json for the latest version:
`> composer update`

If you only want to check this package for newer versions, you can use
`> composer update wika-group/magento2-azure-ad-b2c-sso`

Configuration
-------------

[](#configuration)

The configuration can be found in the admin backend under:
`Stores` -&gt; `Settings` -&gt; `Configuration` -&gt; `WIKA GROUP` -&gt; `Azure B2C`

If you do not want to use the provided button, you can disable it with the "Show button" setting.
To trigger the redirect to Azure for the login, call the route `/azureb2c/login/authorize`.
The response will be processed from the controller `/azureb2c/login/callback`.

[![image](doc/Settings.png)](doc/Settings.png)[![image](doc/CustomerSettings.png)](doc/CustomerSettings.png)

### Autologin after registration in B2C

[](#autologin-after-registration-in-b2c)

The first time a customer is registrating on the shop, the redirect after the registration takes them back to the shop.
But the shop doesn't know that the user is logged in. For this scenario, a GET parameter can be used to automatically redirect the user to the login again.
As the customer is already logged in in B2C, no input is required and a redirect will lead back to the shop, but now the customer will also be logged in to the shop.

[![image](doc/AutologinSettings.png)](doc/AutologinSettings.png)

### Log out from Azure B2C

[](#log-out-from-azure-b2c)

In the admin backend, you can enable logout from Azure B2C after the customer has logged out from Magento.
The observer for the `customer_logout_after` event will check if the logout from Azure B2C is enabled and will redirect to the logout URI from Azure B2C.

Call authorize with referer
---------------------------

[](#call-authorize-with-referer)

By default the authorize controller will read the referer from the request header, store it in the session and redirect back to it in the callback controller.

You can pass a referer as GET parameter to customize the redirect:
`/azureb2c/login/authorize?referer=`

Events
------

[](#events)

### customer\_login

[](#customer_login)

Observers for the event `customer_login` will be triggered if a customer uses Azure B2C to login.

### customer\_logout\_after

[](#customer_logout_after)

The extension adds an additional event after the Session model executed the logout logic.
`customer_logout` is a default event triggered by the Session model before the logout is done.
`customer_logout_after` is triggered after the logout logic in the Session::logout function is executed.

### azure\_b2c\_sso\_\[create|update\]\_customer\_after

[](#azure_b2c_sso_createupdate_customer_after)

The extension triggers an event after a new customer was created and after a customer has been updated.

The event `azure_b2c_sso_create_customer_after` is triggered after this module created a new magento customer.

The event `azure_b2c_sso_update_customer_after` is triggered after this module updated a magento customer. The update also happends after a customer was created.

[More details in official documentation](https://developer.adobe.com/commerce/php/development/components/events-and-observers/)

**Usage of the events**
&lt;vendor\_name&gt;/&lt;module\_name&gt;/etc/events.xml

```

```

&lt;vendor\_name&gt;&lt;module\_name&gt;\\Observer\\SsoCreatedCustomer.php or &lt;vendor\_name&gt;&lt;module\_name&gt;\\Observer\\SsoUpdatedCustomer.php

```
