Configure Keycloak
Rhize uses Keycloak as an OpenID provider. In your cluster, the Keycloak server to authenticate users, services, and manage Role-based access controls.
This topic describes how to set up Keycloak in your Rhize cluster. For a conceptual overview of the authentication flow, read About OpenID Connect
Prerequisites
First, ensure that you have followed the instructions from Set up Kubernetes. All prerequisites for that step apply here.
Steps
Follow these steps to configure a Keycloak realm and associate Rhize services to Keycloak clients, groups, roles, and policies.
Log in
Go to
localhost
on the port where you forwarded the URL. If you used the example values from the last step, that’slocalhost:5101
.Use the container credentials to log in.
To find this, look in the
keycloak.yaml
file.
Create a realm
A Keycloak realm is like a tenant that contains all configuration.
To create your Rhize realm, follow these steps.
- In the side menu, select Master then Create Realm.
- For the Realm Name, enter
libre
. Create. - In the side menu, select Realm Settings.
- Enter the following values:
Field value Frontend URL Keycloak frontend URL Require SSL External requests
After you’ve created the realm, you can create clients.
init
container, configure the Login Theme in Realm settings for libre
.Create clients
In Keycloak, clients are entities that request Keycloak to authenticate a user. You need to create a client for each service.
The DB client requires additional configuration of flows and grants. Other clients, such as the UI and Dashboard, use the standard flow to coordinate authorization between the browser and Keycloak to simplify security and improve user convenience.
Create DB client
Create a client for the DB as follows:
In the side menu, select Clients > create client.
Configure the General Settings:
- Client Type:
OpenID Connect
- Client ID:
libreBaas
- Name:
Libre Backend as a Service
- Description:
Libre Backend as a Service
When finished, select Next.
- Client Type:
Configure the Capability config:
- Client Authentication: On
- Authorization: On
- For Authentication flow, enable:
- 🗸 Standard flow
- 🗸 Direct access grants
- 🗸 Implicit flow
Select Next, then Save.
On success, this opens the Client details page for the newly created client.
Select the Service accounts roles tab and assign the following roles to the
libreBaas
service account. To locate roles, change the filter to Filter by clients:manage-clients
manage-account
manage-users
Create UI client
Create a client for the UI as follows:
In the side menu, select Clients > create client.
Configure the General Settings:
- Client Type:
OpenID Connect
- Client ID:
libreUI
- Name:
Libre User Interface
- Description:
Libre User Interface
When finished, select Next.
- Client Type:
Configure the Capability config:
- Client Authentication: On
- Authorization: On
- For Authentication flow, enable:
- 🗸 Standard flow
- 🗸 Direct access grants
- 🗸 Implicit flow
Configure the Access Settings:
- Root URL:
<UI_SUBDOMAIN>.<YOUR_DOMAIN>
without trailing slashes - Home URL:
<UI_SUBDOMAIN>.<YOUR_DOMAIN>
without trailing slashes - Web Origins:
<UI_SUBDOMAIN>.<YOUR_DOMAIN>
without trailing slashes
- Root URL:
Select Next, then Save.
Create dashboard client
In the side menu, select Clients > create client.
Configure the General Settings:
- Client Type:
OpenID Connect
- Client ID:
dashboard
- Name:
Libre Dashboard
- Description:
Libre Dashboard
- Client Type:
Configure the Capability config:
- Client Authentication: On
- Authorization: On
- For Authentication flow, enable:
- 🗸 Standard flow
- 🗸 Direct access grants
- 🗸 Implicit flow
Configure the Access Settings:
- Root URL:
<DASHBOARD_SUBDOMAIN>.<YOUR_DOMAIN>
without trailing slashes - Home URL:
<DASHBOARD_SUBDOMAIN>.<YOUR_DOMAIN>
without trailing slashes - Valid redirect URIs:
<DASHBOARD_URL>/login/generic_oauth
without trailing slashes - Valid post logout redirect URIs:
+
without trailing slashes - Home URL:
<DASHBOARD_SUBDOMAIN>.<YOUR_DOMAIN>
without trailing slashes
- Root URL:
Select Next, then Save.
Create other service clients
The other services do not need authorization but do need client authentication. By default you need to add only the client ID.
For example, to create the BPMN engine client:
- In the side menu, select Clients > create client.
- For Client ID, enter
libreBpmn
- Configure the Capability config:
- Client Authentication: On
- Select Next, then Save.
Repeat this process for each of the following services:
Client ID | Description |
---|---|
libreAudit | The audit log service |
libreCore | The edge agent |
libreRouter | API router |
Based on your architecture, repeat for any Libre Edge Agents, libreAgent
.
Scope services
In Keycloak, a scope bounds the access a service has. Rhize creates a default client scope, then binds services to that scope.
Create a client scope
To create a scope for your Rhize services, follow these steps:
- Select Client Scopes > Create client scope.
- Fill in the following values:
- Name:
libreClientScope
- Description:
Libre Client Scope
- Type:
None
- Display on consent screen:
On
- Include in token scope:
On
- Name:
- Create.
- Select the Mappers tab, then Configure new mapper. Add an audience mapper for the DB client:
- Mapper Type:
Audience
- Name:
libreBaasAudienceMapper
- Include Client Audience:
libreBaas
- Add to ID Token:
On
- Add to access token:
On
- Mapper Type:
- Repeat the preceding step for a mapper for the UI client:
- Mapper Type:
Audience
- Name:
libreUIAudienceMapper
- Include Client Audience:
libreUI
- Add to ID Token:
On
- Add to access token:
Off
- Mapper Type:
- Repeat the preceding step for a mapper for the BPMN client:
- Mapper Type:
Audience
- Name:
libreBPMNAudienceMapper
- Include Client Audience:
libreBpmn
- Add to ID Token:
On
- Add to access token:
On
- Mapper Type:
- If using the Rhize Audit microservice, repeat the preceding step for an Audit scope and audience mapper:
- Mapper Type:
Audience
- Name:
libreAuditAudienceMapper
- Include Client Audience:
- Included Custom Audience:
audit
- Add to ID Token:
On
- Add to access token:
On
- Mapper Type:
Add services to the scope
- Go to Clients. Select
libreBaas
. - Select the Client Scopes tab.
- Select Add Client scope
- Select
libreClientScope
from the list. - Add > Default.
Repeat this process for the dashboard
, libreUI
, libreBpmn
, libreCore
, libreRouter
, libreAudit
(if applicable). Based on your architecture repeat for any Libre Edge Agent clients.
Create roles and groups
In Keycloak, roles identify a category or type of user. Groups are a common set of attributes for a set of users.
Rhize creates an ADMIN
role and group.
Add the admin realm role
- Select Realm Roles. Then Create role.
- Enter the following values:
- Role name:
ADMIN
- Description:
ADMIN
- Role name:
- Save.
Add the Admin Group
- In the left hand menu, select Groups > Create group.
- Give the group a name like
libreAdminGroup
. - Create.
Now map a role.
- From the group list, select the group you just created.
- Select the Role mapping tab.
- Select Assign Role
- Select
ADMIN
. - Assign.
Add the dashboard realm roles
- Select Realm Roles, and then Create role.
- Name the role
dashboard-admin
. - Save.
- Repeat the process to create a role
dashboard-dev
.
Add the dashboard groups
- In the left hand menu, select Groups, and then Create Group.
- Name the group
dashboard-admin
- Create.
- Repeat the process to create
dashboard-dev
anddashboard-user
groups.
Now map the group to a role:
- Select dashboard-admin from the list
- Select the Role mapping tab.
- Select Assign Role.
- Select
dashboard-admin
- Assign.
- Repeat the process for
dashboard-dev
Add the group client scope
- In the left hand menu, select Client scopes and Create client scope.
- Name it
groups
and provide a description. - Save.
Now map the scope:
- Select the Mappers tab.
- Add predefined mappers.
- Select
groups
. - Add.
Add new client scopes to dashboard client
- In the left hand menu, select Clients, and then
dashboard
. - Select the Client scopes tab.
- Add client scope.
- Select
groups
andlibreClientScope
. - Add Default.
Add Client Policy
In Keycloak, policies define authorization. Rhize requires authorization for the database service.
- In the left hand menu, select Clients, and then
libreBaas
. - Select the Authorization tab.
- Select Policies > Create Policy
- Select Group > Create Policy.
- Name the policy
libreAdminGroupPolicy
. - Select Add Groups.
- Select
libreAdminGroup
. - Add.
- For Logic, choose
Positive
. - Save.
Add users
- In the left hand menu, select Users, and Add User.
- Fill in the following values:
- Username:
system@libremfg.ai
. - Email:
system@libremfg.ai
. - Email Verified:
On
- First name:
system
- Last name:
Libre
- Join Groups:
libreAdminGroup
- Username:
- Create.
Now create a user password:
- Select the Credentials tab.
- Set Password.
- Enter a strong password.
- For Temporary, choose
Off
. - Save.
Repeat this process for the following accounts:
- Audit:
- Username:
libreAudit@libremfg.ai
- Email:
libreAudit@libremfg.ai
- Email Verified:
On
- First name:
Audit
- Last name:
Libre
- Join Groups:
libreAdminGroup
- Username:
- Core:
- Username:
libreCore@libremfg.ai
- Email:
libreCore@libremfg.ai
- Email Verified:
On
- First name:
Core
- Last name:
Libre
- Join Groups:
libreAdminGroup
- Username:
- BPMN
- Username:
libreBpmn@libremfg.ai
- Email:
libreBpmn@libremfg.ai
- Email Verified:
On
- First name:
Bpmn
- Last name:
Libre
- Join Groups:
libreAdminGroup
- Username:
- Router
- Username:
libreRouter@libremfg.ai
- Email:
libreRouter@libremfg.ai
- Email Verified:
On
- First name:
Router
- Last name:
Libre
- Join Groups:
libreAdminGroup
- Username:
- Agent
- Username:
libreAgent@libremfg.ai
- Email:
libreAgent@libremfg.ai
- Email Verified:
On
- First name:
Agent
- Last name:
Libre
- Join Groups:
libreAdminGroup
- Username:
Enable Keycloak Audit Trail
With the libre
realm selected:
- Select Realm Settings, and then Events.
- Select the tab User event settings.
- Enable Save Events and set an expiration.
- Save.
- Repeat the process for the Admin event settings tab.
Configure password policy
With the libre
realm selected:
- Select Authentication and then the Policies tab.
- Select the Password policy tab.
- Add your organisation’s password policy.
Configure brute-force protections
With the libre
realm selected:
- Select Realm settings and then the Security defenses tab.
- In Brute force detection, enable the feature and configure it to your requirements.