Keycloak management
Table of Contents
- Keycloak User and Group Management
Overview
This guide covers user and group management in Keycloak for SAS Retrieval Agent Manager. Keycloak provides centralized identity management, allowing administrators to create users, organize them into groups, and assign roles that control access to application features.
Note: Please be aware that Keycloak is a part of the service mesh installed by the SAS Retrieval Agent Manager helm chart. It is not necessary to install separately or perform any additional initial configuration outside of the helm chart deployment.
Accessing the Admin Console
-
Navigate to the Keycloak Admin Console:
https://<your-domain>/auth/admin -
Log in with administrator credentials
-
Select the retagentmgr realm from the dropdown in the top-left corner
Note: All user and group management should be performed in the
retagentmgrrealm, not themasterrealm.
User Management
Creating Users
-
Navigate to Users in the left sidebar
-
Click Add user
-
Fill in the required fields:
| Field | Description | Required |
|---|---|---|
| Username | Unique login identifier | Yes |
| User’s email address | Yes | |
| First name | User’s first name | No |
| Last name | User’s last name | No |
| Email verified | Mark email as verified | Yes |
| Enabled | Allow user to log in | Yes (default: On) |
Note: If email verification is configured as a required action in your Keycloak instance, users will not be able to log in until their email is verified. Either mark Email verified as On when creating the user, or ensure users complete the email verification process. If email verification is not required, you can leave this field unverified.
- Click Create
Editing Users
-
Navigate to Users → User list
-
Search for the user by username, email, first name, or last name
-
Click on the user to open their profile
-
Modify the desired fields in the Details tab
-
Click Save
Setting User Credentials
-
Open the user’s profile
-
Navigate to the Credentials tab
-
Click Set password
-
Enter the new password and confirmation
-
Configure options:
| Option | Description |
|---|---|
| Temporary | On: User must change password on next login |
| Off: Password is permanent |
- Click Save
Reset Password via Email:
-
Ensure SMTP is configured in Realm Settings → Email
-
Open user profile → Credentials tab
-
Click Reset password under Credential Reset
-
User receives email with password reset link
Disabling and Deleting Users
Disable a User:
-
Open the user’s profile → Details tab
-
Toggle Enabled to Off
-
Click Save
Tip: Disabling users preserves their data while preventing login. Use this for temporary suspensions.
Delete a User:
-
Navigate to Users → User list
-
Find the user and click the three-dot menu (⋮)
-
Select Delete
-
Confirm deletion
Warning: Deleting a user is permanent and removes all associated data.
User Attributes
Custom attributes store additional user information:
-
Open the user’s profile
-
Navigate to the Attributes tab
-
Click Add attribute
-
Enter key-value pair:
| Example Key | Example Value |
|---|---|
department | Engineering |
employeeId | E12345 |
costCenter | CC-100 |
- Click Save
Group Management
Groups organize users and simplify role assignment. All members of a group inherit the group’s roles.
Creating Groups
-
Navigate to Groups in the left sidebar
-
Click Create group
-
Enter a Name for the group
-
Click Create
Suggested Group Structure:
| Group | Purpose |
|---|---|
administrators | Full system access |
developers | Development and testing access |
analysts | Read and analyze data |
viewers | Read-only access |
Group Hierarchy
Groups can be nested to create hierarchical structures:
-
Navigate to Groups
-
Click on a parent group
-
In the subgroups section, click Create group
-
Enter the subgroup name
Example hierarchy:
organization
├── engineering
│ ├── backend-team
│ └── frontend-team
├── data-science
│ ├── ml-engineers
│ └── analysts
└── operations
├── devops
└── support
Note: Child groups inherit all roles from parent groups.
Assigning Users to Groups
From User Profile:
-
Open the user’s profile
-
Navigate to the Groups tab
-
Click Join group
-
Select the group from the tree
-
Click Join
From Group Page:
-
Navigate to Groups
-
Click on the group
-
Go to the Members tab
-
Click Add member
-
Search for and select users
-
Click Add
Remove User from Group:
-
Open user profile → Groups tab
-
Click Leave next to the group
Group Attributes
-
Navigate to Groups → select a group
-
Go to the Attributes tab
-
Add key-value pairs as needed
Role Management
Roles define permissions within the application. Keycloak supports realm roles and client-specific roles.
Warning: Assigning multiple roles to a single user breaks the authorization logic in SAS Retrieval Agent Manager. Each user should have only one role assigned. If you need to combine permissions, use composite roles instead of assigning multiple individual roles to a user.
Realm Roles
Realm roles apply across the entire realm:
-
Navigate to Realm roles in the left sidebar
-
Click Create role
-
Enter role details:
| Field | Description |
|---|---|
| Role name | Unique identifier (e.g., sas_ram_admin_role, sas_ram_user_role) |
| Description | Purpose of the role |
- Click Save
Default Realm Roles:
| Role | Description |
|---|---|
sas_ram_admin_role | Full administrative access |
sas_ram_user_role | Standard user access |
Client Roles
Client roles are specific to an application:
-
Navigate to Clients → select a client
-
Go to the Roles tab
-
Click Create role
-
Enter role name and description
-
Click Save
Composite Roles
Composite roles combine multiple roles:
-
Navigate to Realm roles or Clients → Roles
-
Click on a role
-
Go to the Associated roles tab
-
Click Assign role
-
Select roles to include
-
Click Assign
Example:
admin (composite)
├── user
├── agent-creator
├── agent-executor
└── readonly
Assigning Roles to Users
-
Open the user’s profile
-
Navigate to the Role mapping tab
-
Click Assign role
-
Select Filter by realm roles or Filter by clients
-
Check the roles to assign
-
Click Assign
Assigning Roles to Groups
Assigning roles to groups automatically grants those roles to all group members:
-
Navigate to Groups → select a group
-
Go to the Role mapping tab
-
Click Assign role
-
Select roles to assign
-
Click Assign
Default Roles and Groups
Configure defaults for new users:
Default Roles:
-
Navigate to Realm settings → User registration tab
-
Under Default roles, click Assign role
-
Select roles to assign to all new users
Default Groups:
-
Navigate to Realm settings → User registration tab
-
Under Default groups, click Add groups
-
Select groups for new users to join automatically
Required Actions
Required actions force users to complete tasks on next login:
-
Open user profile → Details tab
-
Under Required user actions, select actions:
| Action | Description |
|---|---|
| Verify Email | User must verify email address |
| Update Password | User must change password |
| Configure OTP | User must set up two-factor auth |
| Update Profile | User must update profile info |
| Terms and Conditions | User must accept terms |
- Click Save
User Sessions
Monitor and manage active user sessions:
View Sessions:
-
Navigate to Sessions in the left sidebar
-
View all active sessions across the realm
Per-User Sessions:
-
Open user profile → Sessions tab
-
View user’s active sessions with details:
- IP address
- Start time
- Last access
- Client applications
Terminate Sessions:
-
From Sessions page: Click Sign out all active sessions in top-right
-
From user profile: Click Sign out next to specific session or Sign out all sessions
Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| User cannot log in | Account disabled | Enable user in profile |
| User cannot log in | Invalid credentials | Reset password |
| User cannot log in | Required action pending | Complete required action |
| Missing permissions | Role not assigned | Assign appropriate roles |
| Group roles not working | User not in group | Verify group membership |
| Cannot create users | Insufficient admin rights | Check admin user roles |
View User Events:
-
Navigate to Events → User events
-
Filter by user, event type, or date
-
Common event types:
LOGIN/LOGIN_ERRORLOGOUTUPDATE_PASSWORDREGISTER
Check Keycloak Logs:
kubectl logs -f deployment/keycloak -n retagentmgr
User Federation and Identity Providers
For integrating external user directories and identity providers, refer to the following guides:
| Integration | Description | Documentation |
|---|---|---|
| LDAP | Connect to LDAP directories (OpenLDAP, Active Directory) | LDAP Configuration |
| OpenID Connect | Integrate with OIDC providers (Azure AD, Okta, Google) | OpenID Connect Configuration |
| SAML | Integrate with SAML 2.0 identity providers | SAML Configuration |