Keycloak Setup Guide for DTaaS
This guide explains how to configure Keycloak for authentication in the DTaaS workspace deployment.
Key Benefits
✅ Standards-Based: Uses OIDC/OAuth2 standards
✅ Enterprise-Ready: Supports SSO, MFA, user federation
✅ Minimal Changes: Environment-variable based configuration
Overview
The configuration uses:
- Keycloak as the identity provider (IdP) with OIDC support
- Traefik Forward Auth to protect routes using OIDC
- Traefik as the reverse proxy
Architecture
Quick Start
In this guide, either <DOMAIN_NAME> OR intocps.org are used as
placeholders for server hostname of the installation.
1. Configure Environment Variables
Keycloak-specific environment variables are:
| Variable | Purpose | Example |
|---|---|---|
KEYCLOAK_ADMIN |
Admin username | admin |
KEYCLOAK_ADMIN_PASSWORD |
Admin password | changeme |
KEYCLOAK_REALM |
Realm name | dtaas |
KEYCLOAK_CLIENT_ID |
OIDC client ID | dtaas-workspace |
KEYCLOAK_CLIENT_SECRET |
OIDC client secret | <from-Keycloak> |
KEYCLOAK_ISSUER_URL |
OIDC issuer URL | https://intocps.org/auth/realms/dtaas |
Edit Keycloak-configuration in .env:
2. Configure Keycloak
The following instructions are part of post-install step.
Access Keycloak Admin Console
- Navigate to
https://intocps.org/auth - Click Administration Console
- Login with credentials from the
.envfile (default:admin/changeme)
Create a Realm
- In the top-left dropdown (currently showing "Master"), click Create Realm
- Realm name:
dtaas(or match theKEYCLOAK_REALMin.env) - Click Create
- Click on Realm Settings -> User Profile
- Click on Create attribute with
- name: profile
- display name: profile
- Permission: who can edit ✅ on admin
- Click Create
Create Users
- In the left sidebar, click Users
- Click Create new user
- Fill in user details:
- Username:
user1(or desired username) - Email: user's email
- First name / Last name: required
- Email verified: OFF
- Profile:
https://intocps.org/auth/realms/dtaas/<USERNAME>The profile URL is created by adding/<USERNAME>to the<REACT_APP_AUTH_AUTHORITY>URL used in theclient.js - Click Create
- Set password:
- Go to the Credentials tab
- Click Set password
- Enter a password
- Temporary: OFF (so users do not have to change it on first login)
- Click Save
- Repeat for additional users (e.g.,
user2)
Create OAuth2 Client for Traefik Forward-Auth Service
- In the left sidebar, click Clients
- Click Create client
- Configure the client:
- Client type: OpenID Connect
- Client ID:
dtaas-workspace(matchKEYCLOAK_CLIENT_IDin.env) - Click Next
- Capability config:
- Client authentication: ON
- Authorization: OFF
- Authentication flow: enable Standard flow
- Click Next
- Login settings:
- Root URL:
https://intocps.org - Valid redirect URIs:
https://intocps.org/_oauth/*https://intocps.org/*
- Valid post logout redirect URIs:
https://intocps.org/* - Web origins:
https://intocps.org - Click Save
- Get the client secret:
- Go to the Credentials tab
- Copy the Client secret value
- Update
KEYCLOAK_CLIENT_SECRETin the.envfile
Create OAuth2 Client for DTaaS Client Service
The DTaaS web client is a React single-page application (SPA) that uses the Authorization Code flow with PKCE (Proof Key for Code Exchange). This requires a public client (no client secret) with PKCE enforced.
- In the left sidebar, click Clients
- Click Create client
- Configure the client:
- Client type: OpenID Connect
- Client ID:
dtaas-client - Click Next
- Capability config:
- Client authentication: OFF (public client — no secret needed)
- Authorization: OFF
- Authentication flow: enable Standard flow only
- Click Next
- Login settings:
- Root URL:
https://intocps.org - Valid redirect URIs:
https://intocps.org/* - Valid post logout redirect URIs:
https://intocps.org/* - Web origins:
https://intocps.org - Click Save
- Enforce PKCE:
- Go to the Advanced tab of the client
- Under Advanced Settings, set
Proof Key for Code Exchange Code Challenge Method to
S256 - Click Save
- Verify scopes:
- Go to the Client Scopes tab of the client
- Confirm that
profileis listed as an assigned scope
3. Restart Services
After configuring Keycloak, restart the services to apply the new client secret:
4. Test Authentication
- Navigate to
https://intocps.org - The browser should redirect to the Keycloak login page
- Log in with one of the created users
- The browser should redirect back to the DTaaS landing page
Production Considerations
To use an external Keycloak instance (recommended for production):
- Update
KEYCLOAK_ISSUER_URLin.env:
Update client redirect URIs in Keycloak to use the production domain
1. Secure Credentials
- Change the default Keycloak admin password
- Use strong client secrets
- Store secrets securely (Docker secrets or external secret managers)
- Rotate secrets regularly
2. Database Backend
For production, configure Keycloak with a proper database (PostgreSQL, MySQL):
Troubleshooting
Cannot Access Keycloak Admin Console
- Ensure the Keycloak service is running:
docker compose ps - Check Keycloak logs:
docker compose logs keycloak - Verify port 80/443 is accessible
Authentication Loop/Redirect Issues
- Verify
KEYCLOAK_ISSUER_URLmatches the realm name - Ensure redirect URIs in the Keycloak client include
/_oauth/* - Confirm
COOKIE_DOMAINmatches the domain - Clear browser cookies and retry
"Invalid Client" Error
- Verify
KEYCLOAK_CLIENT_IDmatches the client ID in Keycloak - Ensure
KEYCLOAK_CLIENT_SECRETis correct - Confirm client authentication is enabled for the client
Forward Auth Not Working
- Check traefik-forward-auth logs:
docker compose logs traefik-forward-auth - Verify environment variables are set correctly
- Ensure Keycloak is reachable from the traefik-forward-auth container
Advanced Configuration
Custom Claims and Scopes
To access custom user attributes:
- In Keycloak, create client scopes with mappers
- Assign scopes to the client
- Configure traefik-forward-auth to request additional scopes
Role-Based Access Control (RBAC)
RBAC is supported in Keycloak but not implemented in the traefik-forward-auth service by default.
Single Sign-On (SSO)
Keycloak supports SSO across multiple applications. Configure additional clients for other services as needed.