Keycloak Administration
Quick Start
Choose your task and load the appropriate reference:
- New Installation → Continue below
- Realm & User Management → Load realm-management.md
- Client Configuration → Load client-configuration.md
- Authentication & SSO → Load authentication-sso.md
- Authorization & RBAC → Load authorization-rbac.md
- User Federation (LDAP/AD) → Load user-federation.md
- Security Hardening → Load security-hardening.md
- High Availability & Scaling → Load ha-scalability.md
- Troubleshooting → Load troubleshooting.md
- Integration Examples → Load integration-examples.md
Installation & Setup
Docker (Recommended for Development)
docker run -d \
--name keycloak \
-p 8080:8080 \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:latest \
start-dev
Production Mode
bin/kc.sh build --db=postgres
export KC_DB=postgres
export KC_DB_URL=jdbc:postgresql://localhost/keycloak
export KC_DB_USERNAME=keycloak
export KC_DB_PASSWORD=password
export KC_HOSTNAME=keycloak.example.com
bin/kc.sh start --optimized
Initial Configuration Checklist
- Admin account — strong password (12+ chars)
- Hostname — configure
KC_HOSTNAME for production
- SSL/TLS — required for production
- Database — PostgreSQL recommended
- SMTP — for email verification and password reset
Core Concepts
| Concept |
Description |
| Realm |
Tenant boundary. Master realm for admin only; create app realms per environment |
| Client |
Application registration. OIDC (modern) or SAML (legacy). Confidential (server) or Public (SPA/mobile) |
| User/Group |
Identity with credentials. Groups for hierarchical organization |
| Realm Role |
Global permission across all clients in a realm |
| Client Role |
Permission scoped to a single client |
| Composite Role |
Role that inherits other roles |
Common Tasks
Configure SSO for an Application
- Create OIDC client with your app's
client-id
- Set Valid Redirect URIs (exact URLs, avoid wildcards)
- Set Client Authentication: On (confidential) or Off (public with PKCE)
- Get discovery endpoint:
{AuthServerUrl}/realms/{realm}/.well-known/openid-configuration
- Integrate with your app — see client-configuration.md
Enable MFA
- Authentication → Flows → Duplicate Browser flow
- Add OTP or WebAuthn authenticator
- Set as Required or Conditional
- Bind custom flow to realm
Connect LDAP/Active Directory
- User Federation → Add LDAP Provider
- Configure: URL, Bind DN, Search Base (
ou=users,dc=example,dc=com)
- Set up attribute mappers
- Test connection, then sync
Essential CLI Commands
# Admin CLI setup
bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user admin
# Realm operations
bin/kcadm.sh create realms -s realm=my-realm -s enabled=true
bin/kcadm.sh get realms/my-realm
# User operations
bin/kcadm.sh create users -r my-realm -s username=john -s enabled=true
bin/kcadm.sh set-password -r my-realm --username john --new-password secret
# Export/Import
bin/kc.sh export --dir /backup --realm my-realm
bin/kc.sh import --dir /backup
Best Practices
- Realm separation: one realm per app/environment, never use Master for apps
- Token lifespans: access tokens 5–15 min, refresh tokens based on use case
- Public clients: always require PKCE
- Roles: use groups for assignment, roles for permissions, composite roles for aggregation
- Production security: SSL/TLS, brute force protection, MFA for admins, event logging
Reference Documentation
- realm-management.md — Realms, users, groups, attributes, sessions
- client-configuration.md — OIDC/SAML clients, scopes, mappers, service accounts
- authentication-sso.md — Auth flows, MFA, identity brokering, social login
- authorization-rbac.md — Roles, fine-grained authorization (UMA), policies, permissions
- user-federation.md — LDAP/AD integration, sync, mappers, custom providers
- security-hardening.md — Password policies, brute force, TLS, audit, production checklist
- ha-scalability.md — Clustering, database tuning, caching, monitoring, backup/DR
- troubleshooting.md — Login failures, token issues, LDAP sync, session problems, logging
- integration-examples.md — .NET, Spring Boot, Node.js, token validation
Source: NikiforovAll/keycloak-authorization-services-dotnet — distributed by TomeVault.
1---2name: nikiforovall-keycloak-authorization-services-dotnet-keycloak3description: Keycloak Administration4---56# Keycloak Administration78## Quick Start910Choose your task and load the appropriate reference:11121. **New Installation** → Continue below132. **Realm & User Management** → Load [realm-management.md](references/realm-management.md)143. **Client Configuration** → Load [client-configuration.md](references/client-configuration.md)154. **Authentication & SSO** → Load [authentication-sso.md](references/authentication-sso.md)165. **Authorization & RBAC** → Load [authorization-rbac.md](references/authorization-rbac.md)176. **User Federation (LDAP/AD)** → Load [user-federation.md](references/user-federation.md)187. **Security Hardening** → Load [security-hardening.md](references/security-hardening.md)198. **High Availability & Scaling** → Load [ha-scalability.md](references/ha-scalability.md)209. **Troubleshooting** → Load [troubleshooting.md](references/troubleshooting.md)2110. **Integration Examples** → Load [integration-examples.md](references/integration-examples.md)2223## Installation & Setup2425### Docker (Recommended for Development)2627```bash28docker run -d \29 --name keycloak \30 -p 8080:8080 \31 -e KEYCLOAK_ADMIN=admin \32 -e KEYCLOAK_ADMIN_PASSWORD=admin \33 quay.io/keycloak/keycloak:latest \34 start-dev35```3637### Production Mode3839```bash40bin/kc.sh build --db=postgres4142export KC_DB=postgres43export KC_DB_URL=jdbc:postgresql://localhost/keycloak44export KC_DB_USERNAME=keycloak45export KC_DB_PASSWORD=password46export KC_HOSTNAME=keycloak.example.com4748bin/kc.sh start --optimized49```5051### Initial Configuration Checklist52531. **Admin account** — strong password (12+ chars)542. **Hostname** — configure `KC_HOSTNAME` for production553. **SSL/TLS** — required for production564. **Database** — PostgreSQL recommended575. **SMTP** — for email verification and password reset5859## Core Concepts6061| Concept | Description |62|---------|-------------|63| **Realm** | Tenant boundary. Master realm for admin only; create app realms per environment |64| **Client** | Application registration. OIDC (modern) or SAML (legacy). Confidential (server) or Public (SPA/mobile) |65| **User/Group** | Identity with credentials. Groups for hierarchical organization |66| **Realm Role** | Global permission across all clients in a realm |67| **Client Role** | Permission scoped to a single client |68| **Composite Role** | Role that inherits other roles |6970## Common Tasks7172### Configure SSO for an Application73741. Create OIDC client with your app's `client-id`752. Set **Valid Redirect URIs** (exact URLs, avoid wildcards)763. Set **Client Authentication**: On (confidential) or Off (public with PKCE)774. Get discovery endpoint: `{AuthServerUrl}/realms/{realm}/.well-known/openid-configuration`785. Integrate with your app — see [client-configuration.md](references/client-configuration.md)7980### Enable MFA81821. Authentication → Flows → Duplicate Browser flow832. Add OTP or WebAuthn authenticator843. Set as Required or Conditional854. Bind custom flow to realm8687### Connect LDAP/Active Directory88891. User Federation → Add LDAP Provider902. Configure: URL, Bind DN, Search Base (`ou=users,dc=example,dc=com`)913. Set up attribute mappers924. Test connection, then sync9394## Essential CLI Commands9596```bash97# Admin CLI setup98bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user admin99100# Realm operations101bin/kcadm.sh create realms -s realm=my-realm -s enabled=true102bin/kcadm.sh get realms/my-realm103104# User operations105bin/kcadm.sh create users -r my-realm -s username=john -s enabled=true106bin/kcadm.sh set-password -r my-realm --username john --new-password secret107108# Export/Import109bin/kc.sh export --dir /backup --realm my-realm110bin/kc.sh import --dir /backup111```112113## Best Practices114115- **Realm separation**: one realm per app/environment, never use Master for apps116- **Token lifespans**: access tokens 5–15 min, refresh tokens based on use case117- **Public clients**: always require PKCE118- **Roles**: use groups for assignment, roles for permissions, composite roles for aggregation119- **Production security**: SSL/TLS, brute force protection, MFA for admins, event logging120121## Reference Documentation122123- [realm-management.md](references/realm-management.md) — Realms, users, groups, attributes, sessions124- [client-configuration.md](references/client-configuration.md) — OIDC/SAML clients, scopes, mappers, service accounts125- [authentication-sso.md](references/authentication-sso.md) — Auth flows, MFA, identity brokering, social login126- [authorization-rbac.md](references/authorization-rbac.md) — Roles, fine-grained authorization (UMA), policies, permissions127- [user-federation.md](references/user-federation.md) — LDAP/AD integration, sync, mappers, custom providers128- [security-hardening.md](references/security-hardening.md) — Password policies, brute force, TLS, audit, production checklist129- [ha-scalability.md](references/ha-scalability.md) — Clustering, database tuning, caching, monitoring, backup/DR130- [troubleshooting.md](references/troubleshooting.md) — Login failures, token issues, LDAP sync, session problems, logging131- [integration-examples.md](references/integration-examples.md) — .NET, Spring Boot, Node.js, token validation132133---134> Source: [NikiforovAll/keycloak-authorization-services-dotnet](https://github.com/NikiforovAll/keycloak-authorization-services-dotnet) — distributed by [TomeVault](https://tomevault.io).135<!-- tomevault:4.0:skill_md:2026-06-18 -->