# Keycloak

> Set up a SAML client in your organization’s Keycloak realm.

Source: https://diakrin.com/docs/sso/keycloak

You need administration access to the correct realm and your [Diakrin setup packet](/docs/sso#get-your-setup-packet). Your identity service must be reachable from the browser; private installations may require your company VPN.

## Create the client

1. In the realm’s **Clients** section, import Diakrin’s SP metadata XML, or create a client with type **SAML**.
2. Set **Client ID** to Diakrin’s SP Entity ID.
3. Set the assertion-consumer POST endpoint to the exact Diakrin ACS URL. Restrict **Valid Redirect URIs** to that URL and use POST binding.
4. Configure EmailAddress NameID using work email, or a stable Persistent NameID. Include a SAML mapper named `email` for the work-email value.
5. Enable signed assertions with RSA-SHA256 and apply access restrictions to your pilot users.

## Map the fields

| Keycloak field | Value |
| --- | --- |
| Client ID | Diakrin SP Entity ID |
| Assertion Consumer Service POST Binding URL | Diakrin ACS URL |
| Valid Redirect URIs | Exact Diakrin ACS URL |
| Name ID Format | Email or agreed Persistent identifier |
| Protocol mapper `email` | Directory work email |

Use the fine-grained ACS endpoint when available. The Master SAML Processing URL also affects logout routing, so review it rather than assuming logout support.

## Activate and test

Obtain the realm’s IdP descriptor at its `/realms/REALM/protocol/saml/descriptor` endpoint. Return the metadata URL or XML, approved domains and certificate expiry to your Diakrin onboarding contact. A metadata endpoint behind a VPN may require the XML-file handoff. After activation, follow [Test and roll out SSO](/docs/sso/testing).

Official reference: [Keycloak server administration — SAML clients](https://www.keycloak.org/docs/latest/server_admin/index.html#_saml_clients).
