SSO Setup: Keycloak¶
Step-by-step instructions for configuring Single Sign-On with JIM using Keycloak as the OIDC identity provider.
Read the overview first
This page is one of the provider-specific guides linked from the SSO Setup overview. The overview covers the prerequisites, the confidential vs public client model these steps rely on, and the testing steps you run once configuration is complete.
Step 1: Create a Realm (if needed)¶
- Log in to the Keycloak Admin Console
- Hover over the realm dropdown and click Create Realm
- Enter a Realm name (e.g.
jim) - Click Create
Step 2: Create a Client for JIM¶
- Navigate to Clients
- Click Create client
- Configure the client:
- Client type: OpenID Connect
- Client ID:
jim
- Click Next
- Configure capability:
- Client authentication: ON
- Authorisation: OFF
- Authentication flow: Check Standard flow (Authorisation Code)
- Click Next
- Configure login settings:
- Root URL:
https://your-jim-url - Valid redirect URIs:
https://your-jim-url/signin-oidc - Valid post logout redirect URIs:
https://your-jim-url/signout-callback-oidc - Web origins:
https://your-jim-url
- Root URL:
- Click Save
Step 3: Get the Client Secret¶
- Go to the Credentials tab
- Copy the Client secret
Step 4: Create a Service Account Client (Optional)¶
If you need separate API clients for service-to-service communication:
- Click Create client
- Configure:
- Client type: OpenID Connect
- Client ID:
jim-service
- Click Next
- Configure capability:
- Client authentication: ON
- Authentication flow: Check Service accounts roles (Client Credentials)
- Click Save
Step 5: Create Client Scopes (for API access)¶
- Navigate to Client scopes
- Click Create client scope
- Configure:
- Name:
jim-api - Type: Optional
- Protocol: OpenID Connect
- Name:
- Click Save
- Go to the Mappers tab
- Click Configure a new mapper
- Select Audience
- Configure:
- Name:
jim-api-audience - Included Client Audience:
jim(orjim-serviceif created) - Add to access token: ON
- Name:
- Click Save
Step 6: Assign the Scope to the Client¶
- Navigate to Clients > jim
- Go to the Client scopes tab
- Click Add client scope
- Select
jim-apiand add as Optional
Step 6a: Configure PowerShell Module Authentication (Recommended)¶
Configuring the PowerShell module now means administrators and automation scripts can connect to JIM interactively with their SSO account, without needing to issue or manage API keys.
The JIM PowerShell module uses OAuth 2.0 with PKCE for interactive browser-based authentication. Keycloak requires this to be a separate client from the confidential web client: a single Keycloak client cannot be both confidential (with a secret) and public (PKCE/loopback). You must create a second, public client and tell JIM about it via JIM_SSO_PUBLIC_CLIENT_ID in Step 7.
- Navigate to Clients
- Click Create client
- Configure the client:
- Client type: OpenID Connect
- Client ID:
jim-powershell(this exact value is what you'll setJIM_SSO_PUBLIC_CLIENT_IDto in Step 7)
- Click Next
- Configure capability:
- Client authentication: OFF (this makes it a public client)
- Authorisation: OFF
- Authentication flow: Check Standard flow (Authorisation Code)
- Click Next
- Configure login settings:
- Root URL: Leave empty
- Valid redirect URIs:
http://localhost:8400/callback/ - Web origins:
+(allows all origins from redirect URIs)
- Click Save
- Go to the Client scopes tab
- Click Add client scope
- Select
jim-apiand add as Optional - Confirm
offline_accessis listed (Keycloak adds it as a default optional scope on new clients). If it is missing, click Add client scope, selectoffline_access, and add it as Optional. This lets the module receive a refresh token for silent renewal and token persistence.
Note
The PowerShell module uses loopback redirect URIs per RFC 8252. If port 8400 is busy, the module will try ports 8401--8409. Add the corresponding redirect URIs (e.g. http://localhost:8401/callback/ through http://localhost:8409/callback/) if port conflicts are likely in your environment.
Step 7: Configure JIM Environment Variables¶
# Keycloak Configuration
JIM_SSO_AUTHORITY=https://{your-keycloak-server}/realms/{realm-name}
JIM_SSO_CLIENT_ID=jim
JIM_SSO_SECRET={your-client-secret}
JIM_SSO_API_SCOPE=jim-api
# Client ID for the public client you created in Step 6a for the PowerShell
# module. Required if you want interactive (SSO) PowerShell authentication;
# omit if you only plan to use API keys.
JIM_SSO_PUBLIC_CLIENT_ID=jim-powershell
# User identity mapping
JIM_SSO_CLAIM_TYPE=sub
JIM_SSO_MV_ATTRIBUTE=Subject Identifier
JIM_SSO_INITIAL_ADMIN={your-admin-sub-value}
Example:
JIM_SSO_AUTHORITY=https://keycloak.example.com/realms/jim
JIM_SSO_CLIENT_ID=jim
JIM_SSO_SECRET=AbCdEfGhIjKlMnOpQrStUvWxYz123456
JIM_SSO_API_SCOPE=jim-api
JIM_SSO_PUBLIC_CLIENT_ID=jim-powershell
Keycloak Troubleshooting¶
- Realm name: Ensure the realm name in
JIM_SSO_AUTHORITYmatches exactly (case-sensitive) - Client scopes: Verify
openid,profile, andemailscopes are included - Token mapper: If the
subclaim is missing, add a mapper in Client Scopes > openid > Mappers
Checking claim values:
- Navigate to Clients > jim > Client scopes
- Click Evaluate
- Select a user and click Evaluate
- Check the Generated access token to see claim values
Next steps¶
With the configuration in place, test your configuration to verify sign-in, claims, sign-out, and API access. If sign-out fails, see Sign-Out Troubleshooting.