OIDC with Keycloak¶
Try it locally first with the Keycloak Compose example, which imports a ready realm.
- In your realm, open Clients, Create client:
- Client type OpenID Connect, client ID
hangar. - Client authentication on; Standard flow on; other flows off.
- Valid redirect URIs:
https://hangar.example.com/auth/oidc/keycloak/callback. - Copy the client secret from the Credentials tab.
- Add a groups claim: Client scopes, Create client scope named
groups, then Mappers, By configuration, Group Membership, token claim namegroups, Full group path off. Add the scope to thehangarclient as a default scope. - Configure Hangar:
oidc:
providers:
- id: keycloak
name: Keycloak
issuer: https://sso.example.com/realms/example
client_id: hangar
scopes: [openid, profile, email, groups]
claims: {username: preferred_username, email: email, name: name, groups: groups}
admin_groups: [hangar-admins]
auto_create_users: true
and set the client secret in a secret, such as HANGAR_OIDC_PROVIDERS as JSON.
Hangar and the browser must both reach the issuer URL exactly as configured, because the issuer in tokens has to match it.