Keycloak SSO Setup
OpenCLM uses Keycloak for authentication. Keycloak provides:
- Single Sign-On (SSO) with SAML 2.0 and OpenID Connect
- LDAP and Active Directory federation
- Multi-factor authentication (TOTP, WebAuthn)
- Social login (Google, Microsoft, GitHub, etc.)
Step 1 — Start Keycloak
Keycloak is included in the Docker Compose stack and starts automatically. Access the admin console at:
http://localhost:8080/admin
Log in with KC_ADMIN_USER / KC_ADMIN_PASSWORD from your .env.
Step 2 — Create the OpenCLM Realm
- In the Keycloak admin console, click Create Realm.
- Set Realm Name to
openclm(or your preferred name — update.envaccordingly). - Enable the realm and click Create.
Step 3 — Create the OpenCLM Client
- In the
openclmrealm, go to Clients → Create client. - Set:
- Client type: OpenID Connect
- Client ID:
openclm-app
- Click Next.
- Enable Standard flow and Direct access grants.
- Set Valid redirect URIs:
https://openclm.yourdomain.com/* - Set Web origins:
https://openclm.yourdomain.com - Click Save.
- In the Credentials tab, copy the Client Secret.
Step 4 — Update .env
KEYCLOAK_URL=https://openclm.yourdomain.com/auth
KEYCLOAK_REALM=openclm
KEYCLOAK_CLIENT_ID=openclm-app
KEYCLOAK_CLIENT_SECRET=<the-client-secret-you-copied>
Step 5 — Restart the API
docker compose restart api
Connecting LDAP / Active Directory
- In Keycloak admin →
openclmrealm → User Federation → Add LDAP provider. - Configure:
- Edit mode: READ_ONLY (or WRITABLE if you want Keycloak to write back to AD)
- Connection URL:
ldap://your-ad-server:389 - Bind DN:
cn=keycloak-service,ou=service-accounts,dc=yourcompany,dc=com - Bind Credential: service account password
- Users DN:
ou=users,dc=yourcompany,dc=com
- Click Test Connection and Test Authentication.
- Click Save then Synchronise all users.
LDAP users can now log into OpenCLM using their company credentials.
Enabling MFA
- In Keycloak admin →
openclmrealm → Authentication → Flows. - Select the Browser flow.
- Set OTP Form to Required.
- Click Save.
Users will be prompted to set up a TOTP app (Google Authenticator, Authy, etc.) on next login.
Social Login (Google, Microsoft)
- In Keycloak admin →
openclmrealm → Identity Providers → Add provider. - Select Google (or Microsoft, GitHub, etc.).
- Enter the OAuth Client ID and Secret from your Google Cloud Console.
- Click Save.
Users can now sign in with "Continue with Google" on the OpenCLM login page.
Keycloak in Production
For production Keycloak deployments:
- Use a dedicated PostgreSQL database for Keycloak (separate from the OpenCLM database).
- Enable cluster mode for high availability.
- Configure a TLS-terminating reverse proxy in front of Keycloak.
- Back up the Keycloak database regularly.
See the Keycloak production guide for comprehensive production hardening.