Set up integration with the enterprise identity provider
Set up integration so that Keycloak delegates authentication to an external enterprise identity provider
Read time 6 minutesLast updated 6 days ago
Integration consists of these phases:
- Create a confidential OAuth client in the enterprise IdP.
- Configure Keycloak with information about this client and the IdP endpoints.
- Update the OAuth client settings in the enterprise IdP, based on the Keycloak configuration.
1. Create a confidential OAuth client in the IdP
In Microsoft Entra ID
Complete these steps:- In Microsoft Entra ID, go to the app registration page.
- Create an app registration in the target tenant. The app registration is an OAuth client. At this stage, no configuration is required, except for a name. This name is a de-facto display name that you can change. You can leave all the other default values as is.
- Create a secret for this client and save it temporarily to a safe place. This secret is required for the configuration of Keycloak. With this secret, the client is confidential. Keycloak uses this secret for authentication.
-
Make a note of this information:
- The application ID (client ID) that is assigned to the new application
- The directory ID (tenant ID)
In Okta
Complete these steps:- In the Okta admin console, select the target Okta organization.
- Go to Applications > Applications.
- Select Create App Integration.
-
Provide these settings during the creation:
-
Sign-in method:
OIDC - Open ID Connect
-
Application type:
web application
-
In the General Settings section:
- App integration name: a descriptive name for the application. This name is a de-facto display name that you can change later.
- Grant type: select .
Client Credentials
-
In the Assignments section:
- Controlled access:
Allow everyone in your organization to access
- Enable immediate access:
Enabled
- Controlled access:
-
Application type:
-
Sign-in method:
-
Make a note of this information:
- The Client ID that is assigned to the new application. This ID is an arbitrary string in this format: .
0oaibyvqhz1CgoBQC5d7
- The client secret that Okta has generated. The client secret is sensitive data.
- The Client ID that is assigned to the new application. This ID is an arbitrary string in this format:
2. Configure Keycloak for integration
Complete these steps:- In the Keycloak admin console, switch to the unity solution realm.
- Go to Configure > Identity Providers.
-
Add a new IdP with these settings:
-
Select the type for the IdP.
OpenID Connect v1.0
-
Select an alias for the IdP. The alias must be a short lowercase string without white spaces, for example, . You can use the same alias for different customers. These requirements are to avoid potential issues, because URIs contain the alias.
unity
- Select a display name for the IdP.
-
Ensure that the Use discovery endpoint setting is enabled. Provide the following value for this field:
-
For Entra ID:
In this URL, replace
https://login.microsoftonline.com/<tenant-id>/.well-known/openid-configuration
with the directory ID from the previous step. For example, for the Unity Entra ID tenant, the URL has this format:<tenant-id>
https://login.microsoftonline.com/45b9a1d4-a8af-40da-8eca-96bebddf6fc7/.well-known/openid-configuration
-
For Okta:
In this URL, replace
https://<org-name>.okta.com/.well-known/openid-configuration
with the name of Okta organization of the enterprise IdP. For example, for the Unity Okta organization, the URL has this form:<org-name>
https://unity.okta.com/.well-known/openid-configuration
-
For Entra ID:
- In the Show metadata section, make sure the values are filled in.
-
Enter this information:
- The client ID, which is the application ID from the previous step.
- The client secret. The client secret must stay in the client configuration, but you don't need to save it. You don't need this value after configuration.
- To create the configuration, select Add.
-
Select the
- Open the newly created IdP.
-
On the Settings tab, change these settings:
- Use PKCE: on
- PKCE method:
S256
-
In the Advanced section, set these values:
- Scopes: add the scope.
openid email profile
- Sync mode:
Force
- Trust email: on
- Scopes: add the
- Select Save.
Mappers
Mappers map the user attributes from the IdP to the Keycloak user attributes. On the Mappers tab, add the mappers for your identity provider. In the Add Identity Provider Mapper window, leave the Sync mode override option toInherit
In Entra ID
Name | Type | Configuration | Purpose |
---|---|---|---|
idp-broker-id | Username template importer |
| Maps the Keycloak user to the Entra ID user by its object ID |
idp-broker-username | Username template importer |
| Maps the Keycloak user to the Entra ID user by its principal name |
idp-attribute-email | Attribute importer |
| Sets the user email in Keycloak based on the IdP user profile |
idp-attribute-firstName | Hardcoded attribute |
| Sets an empty first name for the user in Keycloak |
idp-attribute-lastName | Attribute importer |
| Sets the user's full name in Keycloak based on the IdP user profile |
idp-attribute-enterpriseObjectId | Attribute importer |
| Sets a special custom attribute to the user ID in the IdP |
roles-default-organization-users | Hardcoded role |
| Assigns the user to the default organization on the first sign-in |
In Okta
Name | Type | Configuration | Purpose |
---|---|---|---|
idp-broker-username | Username template importer |
| Maps the Keycloak user to the Okta user by its username |
idp-attribute-email | Attribute importer |
| Sets the user's email address in Keycloak based on the IdP user profile |
idp-attribute-firstName | Hardcoded attribute |
| Sets an empty first name for the user in Keycloak |
idp-attribute-lastName | Attribute |
| Sets the user full name in Keycloak based on the IdP user profile |
idp-attribute-enterpriseObjectId | Attribute importer |
| Sets a special custom attribute to the user ID in Okta |
roles-default-organization-users | Hardcoded Role |
| Assigns the user to the default organization on the first sign-in |
3. Update the OAuth client settings in the enterprise IdP
For Entra ID
For Entra ID, complete these steps:- Go to the app registration for the client, and then go to Properties > Authentication.
-
To add the Keycloak redirect URI to the application properties, add a platform of type . This URI must start with this string:
Web
. If the URI starts withhttps://<solution-domain-name>
, then replace this part withhttp://127.0.0.1
and the correct domain name of the solution. This situation occurs when you access the Keycloak admin console through Kubernetes port forwarding. The full redirect URI has this format:https
.https://<solution-domain-name>*/realms/<realm-name>/broker/<alias>/endpoint
- In the app registration properties, go to Token configuration.
- Add the following optional claims to the ID token:
Claim | Description | Token type |
---|---|---|
email | For example:
|
|
preferred_username | For example:
|
|
For Okta
For Okta, complete these steps:- In the Okta admin console, select the application.
- Go to General Settings.
-
Add the Keycloak redirect URI into the application properties as a sign-in redirect URI.
This URI must start with this string: . If the URI starts with
https://<solution-domain-name>
, then replace this part withhttp://127.0.0.1
and the correct domain name of the solution. This situation occurs when you access the Keycloak admin console through Kubernetes port forwarding. The full redirect URI have this format:https
.https://<solution-domain-name>/realms/<realm-name>/broker/<alias>/endpoint
-
Optionally, set a sign-out redirect URI there to the address:
https://<solution-domain-name>/realms/<realm-name>/protocol/openid-connect/logout
-
Client credentials section:
- The client ID
-
Client secrets section:
- The client authentication method:
client secret
- The client secrets
- The client authentication method:
-
Application section:
-
The application name:
unity-keycloak
-
The application type:
Web
-
For the grant type:
- For the client that acts on its behalf:
Client credentials
- For the client that acts on the user's behalf:
Authorization code
- For the client that acts on its behalf:
-
The application name:
-
User consent section:
- The user consent set as required
-
Login section:
- The sign-in redirect URI:
https://id.dev.transformation.unity.com/realms/sample/broker/okta/endpoint
- The sign-out redirect URI:
https://id.dev.transformation.unity.com/realms/sample/protocol/openid-connect/logout
- The entity that can initiate the login:
App only
- The sign-in redirect URI:
-
Federation Broker Mode section:
- Immediate app access with this mode: enabled