Adding Keycloak identity provider via OpenID Connect
This article shows how to let users sign in to EasyMorph Hub with their Keycloak accounts, using an OpenID identity provider. This feature is available starting from version 6.1.0.
Prerequisites
You will need:
- administrator access to EasyMorph Hub;
- administrator access to the Keycloak realm your users belong to.
The examples below assume the following addresses:
| Service | Example address |
|---|---|
| EasyMorph Hub | http://localhost:6330 |
| Keycloak | http://localhost:8080 |
Adding an OpenID identity provider
-
Sign in to the EasyMorph Hub as an administrator and go to Hub administration.
-
Go to Settings → Identity providers and click Add new. In the Add external IDP dialog, enter a unique Name (for example
Keycloak OpenID), select OpenID as the Type, and click Add.
-
In the Return URL section, check the address that users open EasyMorph Hub with:
- Set Host and Port, or keep the default values. Check Use SSL (HTTPS) if EasyMorph Hub runs over HTTPS. The URLs below change with these settings.
- Copy the Full return URL. Keycloak redirects users back to this address after they sign in.
- (Optional, for back-channel logout) Note the Full logout URL in the Back-Channel Logout section. Keycloak calls this address when a user signs out in Keycloak, so EasyMorph Hub signs them out too. EasyMorph Hub must be reachable from Keycloak at this address.
Keep the page open. You will come back to it after setting up the client in Keycloak.
Creating a client in Keycloak
-
Sign in to the Keycloak administration console. Select your realm in the realm list, go to Clients, and click Create client.
-
On the General settings page:
- Select OpenID Connect as the Client type.
- Enter a Client ID, for example
easymorph-server. You will enter the same ID in EasyMorph Hub later. - (Optional) Enter a Name that Keycloak shows to users, for example
EasyMorph Hub.
Click Next.
-
On the Capability config page:
- Turn Client authentication On. EasyMorph Hub signs in to Keycloak with a client secret.
- Keep Standard flow checked.
- (Optional, recommended) Select a PKCE Method, preferably
S256. The same method must be set in EasyMorph Hub.
Click Next.
-
On the Login settings page, paste the Full return URL from EasyMorph Hub into Valid redirect URIs. Click Save.
-
(Optional, for back-channel logout) Keycloak creates the client and opens its Settings tab. Skip this step if EasyMorph Hub doesn't need to sign users out when they sign out in Keycloak. Otherwise, in the Logout settings section:
- Turn Front channel logout Off. The back-channel settings appear only after that.
- Paste the Full logout URL from EasyMorph Hub into Backchannel logout URL. Keep Backchannel logout session required On.
- (Optional) Turn on Backchannel logout revoke offline sessions to also revoke the user's offline sessions.
- Click Save.
-
Open the Credentials tab of the client and copy the Client Secret.
Keep this page open along with the one on EasyMorph Hub.
Finishing the setup in EasyMorph Hub
-
Go back to the identity provider page in EasyMorph Hub and fill in the Authentication via OpenID section:
- Authority URL - the issuer URL of your Keycloak realm. Usually it is
<Keycloak address>/realms/<realm name>, for examplehttp://localhost:8080/realms/master. Older Keycloak versions, or ones set up with a custom HTTP path, add a prefix such as/auth. To get the exact URL, open Realm settings in Keycloak, click OpenID Endpoint Configuration, and copy theissuervalue. Keycloak must use HTTPS, unless it runs onlocalhost. - Client ID - the client ID from step 5.
- Secret - the client secret from step 9.
- (Optional) Use PKCE - check it if you selected a PKCE method in step 6, and select the same method. Clear it if you didn't.
- (Optional) Support external groups - check it and select Keycloak roles to use Keycloak realm roles as user groups in EasyMorph Hub. See Using Keycloak realm roles as groups.
- Click Save changes.
- Authority URL - the issuer URL of your Keycloak realm. Usually it is
-
(Optional) Click Test - this verifies that Open ID configuration is available from the given Authority Url.
-
Turn the provider toggle to Enabled. The change applies at once, and the status bar shows Identity provider is active.
Users can now select the new provider on the EasyMorph Hub sign-in page and sign in with their Keycloak accounts.
(Optional) Using Keycloak realm roles as groups
With Support external groups set to Keycloak roles, EM treats the user's Keycloak realm roles as groups. You can then give access to a whole role instead of single users.
EasyMorph Hub reads the roles from the realm_access claim of the access token. Keycloak adds this claim through the roles client scope, which is present for new clients by default. You can check it under Client scopes tab:
To give a role access to a space in EasyMorph Hub:
- Go to Spaces, open the space, and go to the Users & Permissions tab.
- Click Add new user/group, select External user group, select the Keycloak identity provider, enter the Keycloak realm role name (for example
easymorph-users), and click Create.
- Assign roles to the new group in the Access control list, the same way as for users.
Note: roles are matched by name, not by ID. Enter the realm role name exactly as it is in Keycloak. Renaming a role will break existing bindings to EasyMorph Hub groups.













