Single Sign-On (SSO) for Apps Using Keycloak as IDP | Keycloak SSO Login

Single Sign-On (SSO) for Apps Using Keycloak as IDP | Keycloak SSO Login


Single-sign-on (SSO) with KeyCloak as IdP (Identity Provider) solution by miniOrange helps you to set up SSO login to your applications/websites using Keycloak. Keycloak Single Sign-On solution can be enabled by configuring Keycloak as SAML IDP in miniOrange, where miniOrange will act as SP. Here in this guide we will see step-by-step process of configuring SSO login between website/application and Keycloak by considering Keycloak as IdP (Identity provider) and miniOrange as SP(Service provider). Once configured successfully you will be ready to securely access your website/application using Keycloak IDP SSO within minutes.

Step 1: Configure Keycloak as Identity Provider (IDP) in miniOrange

Mentioned below are steps to configure KeyCloak as IDP via SAML and OAuth configuration. Follow the steps accordingly based on your requirement (SAML or OAuth).


    Follow the steps to configure Keycloak as IdP by SAML configuration.

  • Go to miniOrange Admin Console.
  • From the left navigation bar select Identity Provider
  • Click on Add Identity Provider button.
  • Configuring Azure AD as IdP : Identity Provider
  • Select SAML. Click on Import IDP metadata.
  • Configuring Azure AD as IdP : IDP metadata
  • Enter IDP name and and browse for the file downloaded in step 2. Click on Import.
  • Configuring Azure AD as IdP: azure ad Import
  • As shown in the below screen the IDP Entity ID, SAML SSO Login URL and x.509 Certificate will be filled from the Metadata file we just imported. Enter the Logout URL copied from Azure AD to Single Logout URL field.
  • Configuring Azure AD as IdP : SAML SSO Login URL and x.509 Certificate
  • Few other optional features that can be added to the Identity Provider(IDP) are listed in the table below:
  • Domain Mapping Can be used to redirect specific domain user to specific IDP
    Show IdP to Users Enable this if you want to show this IDP to all users during Login
    Send Configured Attributes Enabling this would allow you to add attributes to be sent from IDP
  • Click on Save.

Step 2: Configure miniOrange as Service Provider (SP) in Keycloak.

  • Log in to the Keycloak Admin Panel and go to Clients.
  • Keycloak SSO- Go to Clients
  • Click on Create on the right corner of the table.
  • Keycloak SSO- Create Client
  • If you have XML file from service provider, you can click on import file and upload metadata.
  • Keycloak SSO- Import Metadata
  • For manual configuration, Select saml from client protocol dropdown and enter values provided by service provider as follows:
  • Client Id EntityID / Issuer
    Endpoints ACS Url
    Keycloak SSO- Configure client
  • Click on Save for further configuration.
  • Now provide SP configuration values as instructed in table value: .
  • Name Provide a name for this client (Eg. miniOrange)
    Client Protocol SAML
    Sign Assertion On
    Encrypt Assertion Off
    Client Signature Required Off
    Name ID Format Username
    Valid Redirect URIs ACS Url
    Keycloak Client Configuration Keycloak Client Configuration
  • Now in Fine Grain SAML Endpoint Configuration enter values as follows.
  • Assertion Consumer Service POST Binding URL ACS Url
    Logout Service Redirect Binding URL Single Logout Url
    Keycloak Client Configuration
  • Click on the Save button.
  • For IDP metadata, Go to Realms in left panel and click on SAML 2.0 Identity Provider Metadata.

Test Keycloak IDP Connection

  • Go to Identity Providers tab.
  • Click on Select>>Test Connection option against the Identity Provider you configured.
  • Keycloak-IDP-TestConnection
  • On entering valid Keycloak credentials you will see a pop-up window which is shown in the below screen.
  • SucessTestConn-Keycloak-IDP
  • Hence your configuration of Keycloak as an Identity Provider in miniOrange is successfully completed.

    Follow the steps to configure Keycloak as IdP by OAuth configuration.

  • Go to miniOrange Admin Console.
  • From the left navigation bar select Identity Provider. Select Oauth
  • Single Sign-On using Keycloak (miniOrange Identity Provider Dashboard) Single Sign-On using Keycloak(Identity Provider with OAuth 2.0 Provider)
  • Enter the following values.
  • IdP Name Custom Provider
    IdP Display Name Choose appropriate Name
    OAuth Authorize Endpoint https://<keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/auth
    OAuth Access Token Endpoint https://<keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/token
    OAuth Get User Info Endpoint (optional) https://<keycloak domain>/auth/realms/{realm-name}/protocol/openid-connect/userinfo
    Client ID From step 2
    Client secret From step 2
    Scope email profile openid

Step 2: Configure miniOrange as Service Provider (SP) in Keycloak.

  • First of all, Download Keycloak and install it.
  • Start Server: Start the keycloak server by running the _standalone.sh_ file.
  • Root Directory of keycloak bin standalone.sh
  • 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(Add Realm)
  • Create realm: Enter Realm Name and click on CREATE Keycloak SSO(Create Realm).
  • Keycloak Single Sign-On (SSO) - add realm
  • 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(Add a new user)
  • 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(Manage Credentials)
  • 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(Attribute mapping)

    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(select new group)
  • Create groups: Click on the Groups and choose New to create a new group.
  • Keycloak sso(assign user to 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(create OpenId Client)
  • 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(Change access type)
  • Change Access type: After client is created change its access type to confidential.
  • Single Sign-On using Keycloak
  • To get the Redirect URL:
    • Go to miniOrange Admin Console.
    • From the left navigation bar select Identity Provider.
    • Single Sign-On using (miniOrange Identity Provider Dashboard)
    • Copy the Callback URL as Redirect URL required for next step.
    • Single Sign-On using (Identity Provider with OAuth 2.0 Provider)
  • Enter Valid Redirect URLs: Copy callback URL from plugin and then click on SAVE. Ex -- https:///oauth/callback
  •  Keycloak Single Sign-On (SSO) - change access type
  • 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 select Mappers and then click on create. Select mapper type Group Membership and enter name and token claim-name i.e the attribute name corresponding which groups will be fetched. Turn Off full group path and click on Save.
  • Keycloak SSO(Group Mapper)

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

  • Realm name: You need a realm name when you set up Keycloak as an OAuth provider. Go to the Realm Settings tab and copy the realm name.
  • Get Client Secret: Now we need to get client secret. So select Clients and select credentials and copy your secret from here.
  • Keycloak SSO(Jira Test)

3. Configure your Application in miniOrange


Note:

If you have already configured your application in miniOrange you can skip the following steps.


  • Click on Create App under SAML.
  • Click on Create SAML App
  • Search for your Application. In case you do not find your app, search for Custom SAML App.
  • Search for your SAML App Configure SAML Application
  • Get the ACS URL and SP Entity ID from your application.
  • Enter the following values OR click on Import SP Metadata:
  • Service Provider Name Choose appropriate name according to your choice
    SP Entity ID or Issuer Your Application Entity ID
    ACS URL X.509 Certificate (optional) Your Application Assertion Consumer Service URL
    NameID Format  Select urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
    Response Signed Unchecked
    Assertion Signed Checked
    Encrypted Assertion Unchecked
    Group policy Default
    Login Method
  • Click on Save to configure your application.
  • Now to get the IDP metadata of the app configured, Go to apps >> your_app >> select >> metadata tab.
  • Go to the metadata section
  • Click on the Show Metadata details in the Information required to Authenticate via External IDPs section. Download the metadata XML file by clicking on Download Metadata button or copy the Metadata URL link.
  • Downlaod metadata - URL
  • You need to Upload this metadata in your application.
  • Click on Create App under OAuth/OIDC. Click on Open ID Connect App .
  •  Add OAuth openIDConnect app
  • You can add any OAuth Client app here to enable miniOrange as OAuth Server. Few popular OAuth client apps for single sign-on are Salesforce, WordPress, Joomla, Atlassian, etc.
  • Select your OAuth openIDConnect app Configure OAth AddopenIDConnect app
  • Enter following Values:
  • Client Name Add appropriate Name
    Redirect URL Get the Redirect-URL from your OAuth Client
    Descrption Add if required
    Group Name Default
    Policy Name
    Login Method
  • Click on Save
  • Now to provide the required data to OAuth client go to the app configured i.e apps >> your_app >> select >> edit.
  • Edit OAuth editOpenidConnect app OAuth openidConnect app endpoints

    Note: Choose the Authorization Endpoint according to the identity source you configure.

  • When you want to use you want to use miniOrange as OAuth identity server use this endpoint: https://{mycompany.domainname.com}/moas/idp/openidsso
  • If you are configuring any Identity Provider in Identity Providers Menu and not using miniOrange as IDP use this endpoint: https://{mycompany.domainname.com}/broker/login/oauth{customerid}
  • Click on Create App under JWT.
  • Click n External JWT app
  • Select JWT App.
  • SelectJWT app
  • Configure the name for your application and configure Redirect-URL which tells where to send JWT response. Redirect-URL should be an endpoint on your application where you want to achieve SSO.
  • Configure JWT App

    In case you are setting up SSO with Mobile Applications where you can't create an endpoint for Redirect or Callback URL, use below URL.

    https://login.xecurify.com/moas/jwt/mobile

  • Click Save
  • To get the SSO link for your application, Go to Apps >> your_app >> select >> Edit.
  • Get SSO Link
  • Then, copy the Single Sign On Url and verify SSO setup by browsing that url.
  •  SSO URL
  • On successful authentication, you will be redirected to configured Redirect or Callback URL with JWT token
  • You will need to download a certificate from App > Manage Apps, and click Certificate link against your configured application. This certificate will be used for signature validation of JWT response.
  • Download certificate to proceed with SSO

4. Setup Multiple IDPs (Optional)

    You have a choice to set multiple IDPS for Single Application, i.e integrate multiple IDP and users can select IDP accordingly from which they want to authenticate themselves. There are three different ways to authenticate users using IDP.

  • Login using IDP selection page: It gives users an option to Select IDP from the dropdown list during login time.
  • Domain Mapping: Here we map the email domains to a particular IDP. So when the user enters the Email address with a specific domain he would be redirected to the respective IDP.
  • App Identity Provider Mapping: This feature gives users an option to select one specific IDP for their application before login.
  • Note : At once you can select either of them.



  • You can configure multiple IDPs (Identity Providers) and give users the option to select the IDP of their choice to authenticate with.
    For Example - It could be multiple AD domains belonging to different departments or multiple okta organizations.
  • Few usecases where customers configure multiple IDPs -

  • Suppose you have a product which many of your clients use and each client has their own unique IDP so you want them to SSO into your product as well using their existing IDP only. miniOrange provides a centralized way to connect with all IDPs in a very easy manner and integrate SSO into your application.
  • Suppose you are providing a course to many universities, each having a unique SAML, OAuth protocol supported IDP's like Shibboleth, ADFS, CAS, etc. You can provide Single Sign-On (SSO) into your course application to all these universities by integrating with all of them using a single platform provided by miniOrange.
  • This is the endpoint to call from your SAML application -
    For Cloud IDP - https://login.xecurify.com/moas/discovery?customerId=<customer_id>
    For On-Premise IDP - https://yourdomain.com/discovery?customerId=<customer_id>
  • You should copy the Customer Key from admin console-> Settings -> and replace it with <customer_id> here. Once configured in SP, when you initiate the login from Service Provider, a user will be redirected to IDP Selection Page listing all IDPs configured for that account.
  • You can see the screenshot below of the IDP Selection Page with a list of IDPs .

    Note: To view the IDP in drop-down list, go to Identity Providers tab > against your configured IDP > Select >Edit , here Enable the Show IdP to Users option.

    Select your IDP (Identity Provider) to login

  • You can also change the look and feel of this page. Login to miniOrange Admin console. Navigate to Customization -> Branding Configuration. See the below screenshot for reference-
    Customize IDP selection login page
  1. You can customize the title of this page.
  2. Change the logo and favicon for this page.
  3. Change the background and button color for this page from admin UI.

If you have multiple IDPs and you want a certain set of users to authenticate from one IdP whereas another set of users to authenticate from another IdP, based on their email domains you can achieve this by using the following steps:- Our domain mapping feature

  • We have provided a Domain Mapping field under each IdP where admins can enter the domain eg. demo.com , example.com as shown in the screenshot below.
  • Domain Mapping for selected IDP SSO

    Lets say, there are two organisations under ADFS. One want to authenticate the users under the domain demo.com and other one with the domain example.com. For reference, We have taken the 2 organisations as two different IDPs and WordPress as SP. Follow the guides to set up ADFS and WordPress at your end.

  • Once the setup is complete you can login through your Wordpress site.
  • So a user logging in with the demo.com domain will be redirected to the first organisation under ADFS.
  • Selected IDP Login Page


  • User logging in with email address having example.com domain will be redirected to the second organisation under ADFS.
  • Different Domain IDP SSO login
    SSO Login Page for the selected domain
  • Once the user will authenticate itself through respective Organisations under ADFS, it will be redirected back to Wordpress site.

    If you have multiple IDPs (identity provider) and you want a certain application user to authenticate with one IDP and other application users with another IDP then you can achieve this by our Identity Source Feature.

  • Go to apps >> your_app >> select >>edit.
  • Edit SAML app
  • Here you will have an option called as an Identity source.
  • The dropdown list would show the list of configured IDPs (Identity providers) in miniOrange Identity Providers tab and Userstore.
  • Select one IDP you want for this application. Click on Save.
  • Select IDP from which you want to authenticate users
  • Now the users of this application would be able to authenticate only by the IDP (Identity Provider) selected from the Identity Source dropdown list.

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