Step By Step Guide For WordPress Single Sign On (SSO) using Keycloak

Step By Step Guide For WordPress Single Sign On (SSO) Using Keycloak



If you want users to login to your WordPress site using their keycloak credentials, you can simply do it using our WP OAuth Client plugin. Once you configure the keycloak with WordPress plugin, you can allow users to SSO to your WordPress site using keycloak. Similarly, you can map your WordPress roles based on your keycloak attributes/groups. To know more about other features we provide in WP OAuth Client plugin, you can click here.



You can download OAuth Client plugin using the following link.




Download And Installation

  • Log into your WordPress instance as an admin.
  • Go to the WordPress Dashboard -> Plugins and click on Add New.
  • Seach for a WordPress OAuth Single Sign On plugin and click on Install Now.
  • Once installed click on Activate.

Step 1: Setup Keycloak as OAuth Provider

  • 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.
  • OAuth/OpenID Keycloak Single Sign On SSO add realm
  • Create realm: Enter Realm Name and click on CREATE to 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.
  • OAuth/OpenID Keycloak Single Sign On SSO add role
  • 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.
  • OAuth/OpenID Keycloak Single Sign On SSO 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.

    OAuth/OpenID Keycloak Single Sign On SSO 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.
  • OAuth/OpenID Keycloak Single Sign On SSO map user
  • Create groups: Click on the Groups and choose New to create a new group.
  • OAuth/OpenID Keycloak Single Sign On SSO 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.
  • OAuth/OpenID Keycloak Single Sign On SSO assign group
  • 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.
  • OAuth/OpenID Keycloak Single Sign On SSO client id
  • Change Access type: After client is created change its access type to confidential.
  • OAuth/OpenID Keycloak Single Sign On SSO change access type
  • Enter Valid Redirect URIs: Copy callback URL from plugin and then click on SAVE. Ex -- https:///oauth/callback
  • 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.
  • OAuth/OpenID Keycloak Single Sign On 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.
  • OAuth/OpenID Keycloak Single Sign On SSO client id client secret
  • Plugin Configuration: Enter copied Client Secret here Client ID will be your client name and the URL are given below.

  • Keycloak Endpoints and Scope:


    Client ID : Click Here
    Client Secret : Click Here
    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

Step 2: Setup WordPress as OAuth Client

  • After Plugin is activated, go to the plugin and search for Keycloak. Select Keycloak from the OAuth Providers list.
  • OAuth/OpenID Keycloak Single Sign On SSO select Keycloak as OAuth Provider
  • Go to Configure OAuth tab and configure App Name, Client ID, Client Secret from provided Endpoints.
  • openid is already filled but if it doesn't work then configure scope as User.Read and for fetching group info use scope is Directory.read.all.
  • Click on Save Settings to save the configuration.
  • OAuth/OpenID Keycloak Single Sign On SSO  save settings

Step 3: User Attribute Mapping.

  • User Attribute Mapping is mandatory for enabling users to successfully login into WordPress. We will be setting up user profile attributes for WordPress using below settings.
  • Finding user attributes

    • Go to Configure OAuth tab. Scroll down and click on Test Configuration.
    • OAuth/OpenID Keycloak Single Sign On SSO test congifuration
    • You will see all the values returned by your OAuth Provider to WordPress 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.
    • OAuth/OpenID Keycloak Single Sign On SSO test congifuration result
    • Once you see all the values in Test Configuration, go to Attribute / Role Mapping tab, you will get the list of attributes in a Username dropdown.
    • OAuth/OpenID Keycloak Single Sign On SSO attribute/role mapping

Step 4: Login Settings / Sign In Settings.

  • The settings in SSO Settings tab define the user experience for Single Sign On. To add a login widget on your WordPress page, you need to follow below steps.
  • Sign In Settings

    • Go to WordPress Left Panel > Appearances > Widgets.
    • Select miniOrange OAuth. Drag and drop to your favourite location and save.
    • OAuth/OpenID Keycloak Single Sign On SSO login button setting
    • Open your WordPress page and you can see the login button there. You can test the SSO now.

Need Guidance?

Mail us on oauthsupport@xecurify.com for quick guidance(via email/meeting) on your requirement and our team will help you to select the best suitable solution/plan as per your requirement.