Search Results :

×

Magento Keycloak Single Sign-On (SSO) | SSO into Magento using Keycloak Credentials

The Keycloak Magento SSO enables secure and seamless login to your Magento by using Keycloak as your OAuth and OpenID Connect provider. With Keycloak Magento SSO login, users can access the store using Keycloak login credentials. This means with our extension, users of your Keycloak can login into your Magento store using their Keycloak login cedentials.

Our Magento Keycloak Login extension provides secure Single Sign-On (SSO) integration with advanced features like attribute mapping, role mapping, and access control. It enhances site security by ensuring that only verified users can log in or register your Magento site. With a simple Magento Keycloak SSO setup process, the extension streamlines user authentication and improves overall access management. Follow the guide below to install and configure Keycloak Magento SSO effortlessly.

Click here to read more about the Magento OAuth Single Sign-On (OAuth & OpenID Connect Client) extensions extra features.

  • Purchase the miniOrange Magento OAuth Single Sign-On (SSO) extension from Magento Marketplace (Adobe Commerce Marketplace).
  • Go to My profile -> My Purchases
  • Please ensure you are using correct access keys (My Profile - Access Keys)
  • Paste the access keys in your auth.json file inside your project
  • Use the below command to add the extension to your project.
    "composer require {module_name}:{version}"
  • You can see the module name and list of versions in the selector below the extension module name.
  • Run the following commands on command prompt to enable the extension.
  • php bin/magento setup:upgrade
  • Download the miniOrange Magento OAuth Single Sign-On (SSO) extension.
  • Unzip all contents of the zip inside the MiniOrange/IDPSaml directory.
  • {Root Directory of Magento} app code MiniOrange OAuth
  • Run the following commands on command prompt to enable the extension
  • php bin/magento setup:upgrade

  • First of all, Download Keycloak and install it.
  • Start the keycloak server based on your keycloak version. (See table below)

For the Keycloak Version 16 and below

Go to the Root Directory of keycloak bin standalone.sh

For the Keycloak Version 17 and above

Go to the Root Directory of keycloak bin kc.bat and run the below commands.
1. kc.bat build
2. kc.bat start-dev


Follow the following steps to configure Keycloak as IdP to achieve Magento Keycloak SSO

Select Keycloak version:
    • Add Realm : Now login to keycloak administration console and navigate to your desired realm. You can add new realm by selecting Add Realm option.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - add realm
    • Create realm: Enter Realm Name and keep the realm name handy as it will required later to configure the Realm under the OAuth Client plugin. Click on CREATE to add realm.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - add realm
    • Create OpenID client: Click on the Clients and choose create to create a new client. Enter client id and select client protocol openeid-connect and select Save.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - client id
    • Change Access type: After client is created change its access type to confidential.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - change access type
    • Enter Valid Redirect URIs: Copy callback URL from Magento Keycloak SSO extension and then click on SAVE. Ex -- https:///oauth/callback

    • Keycloak SSO - Keycloak OAuth Single Sign-On - change access type
    • Get Client Secret: Now we need to get client secret. So select Clients and select credentials and copy your secret from here.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - client id client secret
    • Plugin Configuration: Enter copied Client Secret under Client secret field in the OAuth Client plugin, and enter the Client Name under the Client ID field.
    • Add User: We need to add users to realm who will be able to access the resources of realm. Click on the Users and choose to Add a new User.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - add user
    • User Configuration: After user is created following action needs to be performed on it.
      • 1) Setting a password for it so click on Credentials and set a new Password for the user.


      Keycloak SSO - Keycloak OAuth Single Sign-On - set password

      NOTE : Disabling Temporary will make user password permanent.

    • Map User: We need to map user to a role. Click on Role Mappings and assign the user desired role from available roles and clicking on add selected.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - map user
    • Create ROLE: The Role will be used by your applications to define which users will be authorized to access the application. Click on the Roles and choose Add Role.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - add role

      Step 1.1: Steps to fetch Keycloak Groups [Premium]

      • Create groups: Click on the Groups and choose New to create a new group.

      • Keycloak SSO - Keycloak OAuth Single Sign-On - create group
      • Assign user to group: Select the user whom you want to add in group. Choose Groups option from tab and then select the group-name and click on join.

      • Keycloak SSO - Keycloak OAuth Single Sign-On - assign group
      • Keycloak Group Mapper: Now to get group details we need to perform its client mapping with group membership else group details will not be fetched. So in Client section, select your client and then click on mapper->create.

      • Keycloak SSO - Keycloak OAuth Single Sign-On - group mapper
        Keycloak SSO - Keycloak OAuth Single Sign-On - group mapper
      • Now, select mapper type as Group Membership and enter the name and token claim name i.e the attribute name corresponding to which groups will be fetched. Turn Off the full group path, Add to ID token and Add to access token options, and click on Save.

      • Keycloak SSO - Keycloak OAuth Single Sign-On - group mapper

        Note: -- If full path is on group path will be fetched else group name will be fetched.

      Step 1.2: Steps to fetch Keycloak Roles [Premium]

      • Keycloak Role Mapper: Now to get role details we need to perform its client mapping with role membership else role details will not be fetched. So in Client section, select your client and then click on mapper->create.

      • Keycloak SSO - Keycloak OAuth Single Sign-On - group mapper
        Keycloak SSO - Keycloak OAuth Single Sign-On - group mapper
      • Now, select mapper type as user realm Role Membership and enter the name. and token claim name i.e the attribute name corresponding to which groups will be fetched. Add to ID token and Add to access token options, and click on Save.

      • Keycloak SSO - Keycloak OAuth Single Sign-On - group mapper
    • Add Realm : Now login to keycloak administration console and navigate to your desired realm. You can add new realm by selecting Create Realm option.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Add realm
    • Create realm: Enter Realm Name and keep the realm name handy as it will required later to configure the Realm under the OAuth Client plugin. Click on CREATE to add realm.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Create realm
    • Create OpenID client: Click on the Clients and choose Create Client to create a new client. Enter Client id and select client protocol openeid-connect and Click Next.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Create client
      Keycloak SSO - Keycloak OAuth Single Sign-On - Add client id
    • Enable the Client Authentication and Authorization toggle.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Enable toggle
    • Scroll down to the Access settings and enter your Callback/Redirect URL which you will get from Magento Keycloak SSO extension present under the CallBack URLs text-field.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - callback url
    • Go to the Credentials tab, copy the Client Secret and keep it handy as we will require it later while configuring Magento Keycloak SSO extension.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Copy client secret
    • Plugin Configuration: Enter copied Client Secret under Client secret field in the OAuth Client plugin, and enter the Client ID under the Client ID field.
    • Add User: We need to add users to realm who will be able to access the resources of realm. Click on the Users and Click on Create new user to Add a new User.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Add user
    • User Configuration: After user is created following action needs to be performed on it.
      • 1) Setting a password for it so click on Credentials and set a new Password for the user.


      Keycloak SSO - Keycloak OAuth Single Sign-On - set password

      NOTE : Disabling Temporary will make user password permanent.

    • Map User: We need to map user to a role. Click on Role Mappings and assign the user desired role from available roles.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - map user
    • Create ROLE: The Role will be used by your applications to define which users will be authorized to access the application. Click on the Roles and choose Create Role.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - add role
    • Add Realm : Now login to keycloak administration console and navigate to your desired realm. You can add new realm by selecting Create Realm option.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Add realm
    • Create realm: Enter Realm Name and keep the realm name handy as it will required later to configure the Realm under the OAuth Client plugin. Click on CREATE to add realm.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Create realm
    • Create OpenID client: Click on the Clients and choose Create Client to create a new client. Enter Client id and select client protocol openeid-connect and Click Next.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Create client
      Keycloak SSO - Keycloak OAuth Single Sign-On - Add client id
    • Enable the Client Authentication and Authorization toggle.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Enable toggle
    • Scroll down to the Access settings and enter your Callback/Redirect URL which you will get from Magento Keycloak SSO extension CallBack URLs text-field.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - callback url
    • Go to the Credentials tab, copy the Client Secret and keep it handy as we will require it later while configuring Magento Keycloak SSO extesnion.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Copy client secret
    • Plugin Configuration: Enter copied Client Secret under Client secret field in the OAuth Client plugin, and enter the Client ID under the Client ID field.
    • Add User: We need to add users to realm who will be able to access the resources of realm. Click on the Users and Click on Create new user to Add a new User.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - Add user
    • User Configuration: After user is created following action needs to be performed on it.
      • 1) Setting a password for it so click on Credentials and set a new Password for the user.


      Keycloak SSO - Keycloak OAuth Single Sign-On - set password

      NOTE : Disabling Temporary will make user password permanent.

    • Map User: We need to map user to a role. Click on Role Mappings and assign the user desired role from available roles.

    • Keycloak SSO - Keycloak OAuth Single Sign-On - map user


    In conclusion, by successfully configuring Keycloak as OAuth Provider, you have enabled Magento Keycloak SSO Login and authorization for your end users into Magento.

  • After successfully configuring OAuth Provider, go to OAuth Providers tab and click on Add Provider button.
  • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Settings
  • Now, Enter the OAuth Provider Name, Client ID, Client Secret, Scope and provided endpoints.
  • Please refer the below table for configuring the scope & endpoints for Keycloak Version 18 and above in the extension.
    • Scope: email profile openid
      Authorize Endpoint: <keycloak domain>/realms/{realm-name}/protocol/openid-connect/auth
      Access Token Endpoint: <keycloak domain>/realms/{realm-name}/protocol/openid-connect/token
      Get User Info Endpoint: <keycloak domain>/realms/{realm-name}/protocol/openid-connect/userinfo
      Custom redirect URL after logout:[optional] https://{keycloak domain}/realms/{realm-name}/protocol/openid-connect/logout?post_logout_redirect_uri={RedirectUri}&id_token_hint=##id_token##
  • Please refer the below table for configuring the scope & endpoints for Keycloak Version 17 and below in the extension .
    • Scope: email profile openid
      Authorize Endpoint: <keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/auth
      Access Token Endpoint: <keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/token
      Get User Info Endpoint: <keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/userinfo
      Custom redirect URL after logout:[optional] <keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=RedirectUri
  • Click on the Save button to save the settings.
  • Click on the Test Configuration button.
  • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Save settings
  • You will see all the values returned by your OAuth Provider to Magento 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.
  • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Test Config
    Note and Contact Us - SSO Magento Keycloak Login

    Note: In the Enterprise Version of the extension you can setup multiple providers. To setup a different provider click on the Add Provider button and setup your required provider. You can find the setup guides of all the providers from here.

    • Navigate to Multisite Settings tab. Here you can all the subsites under your Magento Installation where you wish to enable the SSO. You can check the checkbox against all the subsites and click on save.
    • You would also see the Callback URL for each subsite which you can use to setup the required OAuth Provider.
    • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Multisite Settings
    • Navigate to Sign-in Settings tab and Choose the OAuth Provider from the dropdown menu to proceed with the configuration.
    • Here you find the option the enable the login link on Admin*/Customer Login Page (*Admin SSO is available in the premium versions)
    • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Admin Customer Link
    • You can automatically create Admin and Customer users during SSO if they don't already exist. Simply enable the corresponding checkbox to activate.
    • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Auto Create Users
    • 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.
    • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Redirect users
    • If you want to initate SSO from any page you can also use the SSO link provided in the extension.
    • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - SSO Link
  • Go to customer login page and you will see the SSO button on your frontend. Click on the button and test the SSO.
Magento 2 OAuth SSO customer SSO

  • You will be sucessfully logged in into Magento.
magento SSO magento 2 OAuth client SSO Admin SSO

  • Visit your admin login page and you will see the SSO button on your admin page. Click on the button to initate SSO as an admin.
Magento 2 Admin SSO login button

  • After sucessfully logged into magento as admin you will be redirect to magento backend dashboard.
Magento 2 Admin SSO admin dashboard

  • Navigate to Sign-in Settings tab. Here you find the option the enable the SSO for your Headless Magento Store.
  • Paste your Frontend Post URL in the given field. You should enter your frontend store URL here.
Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - Headless SSO

  • Attributes are user details that are stored in your Identity Provider.
  • Attribute Mapping helps you to get user attributes from your Identity Provider (IdP) and map them to Magento user attributes like firstname, lastname etc.
  • While auto registering the users in your Magento site these attributes will automatically get mapped to your Magento user details.
  • Only NameID can be mapped to Magento's Email and Username characteristics with the free plugin. Multiple user attributes from the IdP, on the other hand, can be mapped to Magento attributes in the premium version of the plugin. You can map custom attributes that you've added to your IdP in addition to the default attributes.
  • When a user performs SSO, the NameID value sent by the IdP will get mapped to the email and the username of the Magento user.
Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - attribute mapping

    Username: Name of the username attribute from IdP (Keep NameID by default)
    Email: Name of the email attribute from IdP (Keep NameID by default)
    Group/Role: Name of the Role attribute from Identity Provider (IdP)
  • You can check the Test Configuration Results under Service Provider Setup tab to get a better idea of which values to map here.
  • In the Enter Attribute Name field enter the Attribute Name you wish to map against the attribute you are receiving from your Identity Provider.
  • Click on Add button
  • Now, Enter the attribute name your are receiving from your Identity Provider in the provided field.
  • 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.
Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - custom attribute mapping

  • Magento uses a concept of Roles, designed to give the site owner the ability to control what users can and cannot do within the site. Role mapping helps you to assign specific roles to users of a certain group in your IdP.
  • While auto registering, the users are assigned roles based on the group they are mapped to.
  • You can specify a default role in the POC extension that will be allocated to all non-admin users when they conduct SSO.
  • Select the Default Role which you want to assign to all the non-admin users and click on the Save button.
  •  Magento Keycloak SSO - Login | Magento 2 Keycloak SSO - role mapping Customers
  • You also have the ability to Update the Backend/Frontend Roles on SSO in the premium extension.
  • You can also specify a default role that will be allocated to all non-admin users when they conduct SSO in the premium extension.
  • Select the Default Role which you want to assign to all the admin users and click on the Save button.
  • Magento Keycloak SSO - Login | Magento 2 Keycloak SSO- role mapping

    Please reach out to us at magentosupport@xecurify.com, and our team will assist you with setting up the Magento 2 SSO (OAuth/OIDC) Extension. Our team will help you to select the best suitable solution/plan as per your requirement.

ADFS_sso ×
Hello there!

Need Help? We are right here!

support