Keycloak configuration
Configure how Keycloak is deployed to your Red Hat® OpenShift® Container Platform cluster (including storage options, deployment size) and how authorization and authentication are handled (including TLS configuration, password handling, and advanced configuration options).
Complete list of topics:
Storage options
Keycloak uses either the default storage class in Red Hat OpenShift Container Platform, or the storage class configured in the IBM Cloud Pak® foundational services custom resource. Before installing instances, do one of the following:
Set a default storage class by adding the
storageclass.kubernetes.io/is-default-class:'true'
annotation in Red Hat OpenShift Container Platform.Specify a storage class name for
spec.storageClass
in theCommonService
resource.
The following are characteristics of the database that Keycloak uses:
Requires block storage that is configured to use the
XFS
orext4
file system. RWOaccessMode
is required. The file systems (XFS
andext4
) are POSIX-compliant and fully compatible with all supported OpenShift Container Platform releases.- Supports a
volumeBindingMode
of eitherImmediate
orWaitForFirstConsumer
to control volume binding and dynamic provisioning.Important: If your installation is in an environment with multiple availability zones, the value ofvolumeBindingMode
must beWaitForFirstConsumer
. Otherwise, the Keycloak installation will fail.
Backup and restore
You can back up and restore Keycloak data by using the Red Hat OpenShift API for Data Protection (OADP). For more information, see Backing up and restoring IBM Cloud Pak for Integration.
Password policy
The default password policy for Keycloak users in Cloud Pak for Integration is the following:
Must be at least 15 characters long.
Cannot contain the username.
Cannot contain the email address.
To customize the password policy:
Access the Keycloak Administration console. For more information on accessing this Administration console, see Advanced Keycloak administration.
Select
cloudpak
from the realm selector.Click Configure > Authentication.
Click the Policies tab.
Click the Password policy sub-tab.
Update the password policy as needed.
Click Save.
For more information, see Password policy in the Red Hat documentation.
Password reset
You can enable Keycloak users to reset their own passwords.
In addition to the steps in this section, make sure to update the email server settings in the "Configuring email" section, so that Keycloak can use a user's email address to reset their password.
Log in to the Platform UI as a user with realm management permissions. For more information, see Cloud Pak roles and permissions.
Click the Navigation Menu icon next to IBM Cloud Pak for Integration in the banner, then click Administration > Access control. The Keycloak access control console opens.
In the navigation pane, click Realm settings.
Click the Login tab.
Enable the Forgot password option.
Email verification
There are two options for configuring user email verification in Keycloak:
Enable email verification - Configure Keycloak to send emails that verify those user email addresses.
Disable email verification - Configure Keycloak so that it automatically trusts email addresses discovered by using an identity provider or federated user store. For more information, see the documentation for configuring identity providers or federated user stores in Managing users and groups.
To enable or disable email verification:
Log in to the Platform UI as a user with realm management permissions. For more information, see Cloud Pak roles and permissions.
Click the Navigation Menu icon next to IBM Cloud Pak for Integration in the banner, then click Administration > Access control. The Keycloak access control console opens.
In the navigation pane, click Realm settings.
Click the Login tab.
Set the Verify email option to on if you want to enable email verification. To disable email verification, set the option to off.
Configuring email
To configure Keycloak to send email:
Log in to the Platform UI as a user with realm management permissions. For more information, see Cloud Pak roles and permissions.
Click the Navigation Menu icon next to IBM Cloud Pak for Integration in the banner, then click Administration > Access control. The Keycloak access control console opens.
In the navigation pane, click Realm settings.
Click the Email tab.
Enter your email server settings.
Click Save.
For more information, see Configuring email for a realm in the Red Hat documentation.
Timeouts
You can configure the idle timeout and maximum session length for Cloud Pak for Integration by changing Keycloak realm settings.
Log in to the Platform UI as a user with realm management permissions. For more information, see Cloud Pak roles and permissions.
Click the Navigation Menu icon next to IBM Cloud Pak for Integration in the banner, then click Administration > Access control. The Keycloak access control console opens.
In the navigation pane, click Realm settings.
Click the Sessions tab.
Configure timeout on the Sessions page. The SSO Session Idle setting controls how long a user can be idle before they are automatically logged out. The SSO Session Max controls the maximum length of time that a user can be logged in before they have to reauthenticate.
Click Save.
For more information, see User session timeouts in the Red Hat documentation.
Keycloak API
Use the Keycloak API to perform identity and access management operations. The Keycloak realm is cloudpak
.
Get the Keycloak hostname from the URL of the Red Hat Build of Keycloak console:
Log in to the Platform UI as a user with realm management permissions. For more information, see Cloud Pak roles and permissions.
Click the Navigation Menu icon next to IBM Cloud Pak for Integration in the banner, then click Administration > Access control. The Keycloak access control console opens.
Copy the hostname from the URL.
For more information, see API documentation in the Red Hat documentation.
Customizing the default hostname
Keycloak has an OpenShift route with a hostname that has the format https://keycloak-<namespace>.apps.<cluster domain>
.
To customize the hostname, you must be a user with namespace admin permissions. For more information, see OpenShift roles and permissions.
Change the
.data.keycloak_route_name
parameter value in theibm-cpp-config
ConfigMap to your custom hostname:kind: ConfigMap apiVersion: v1 metadata: name: ibm-cpp-config namespace: <keycloak-namespace> data: keycloak_route_name: <hostname>
To apply the configuration changes, restart the
operand-deployment-lifecycle-manager
pod in your operator namespace:oc delete pods -l app.kubernetes.io/instance=operand-deployment-lifecycle-manager -n <operator namespace>
Customizing the TLS configuration
Keycloak uses the OpenShift apps domain and the OpenShift router certificate.
To customize the certificate, you must be a user with namespace admin permissions. For more information, see OpenShift roles and permissions.
Generate the following custom certificates in an unencrypted PEM format:
tls.crt
- Contains the certificate, which is valid for the specific custom hostname.tls.key
- Contains the private key of the certificate.ca.crt
- (Optional) You can specify a CA certificate, if needed, to complete the certificate chain.
Identify the namespace that contains the Keycloak route. For installations using A specific namespace on the cluster mode, this is the same namespace where your instances are deployed. For installations using All namespaces on the cluster mode, this is the
servicesNamespace
defined in theCommonService
resource (which isibm-common-services
by default).Set this namespace as an environment variable to use in further commands:
KEYCLOAK_NAMESPACE=<namespace>
Create a secret named
keycloak-custom-tls-secret
by using the custom certificates that you created in the first step:oc create secret generic keycloak-custom-tls-secret --from-file=tls.crt=tls.crt --from-file=tls.key=tls.key -n ${KEYCLOAK_NAMESPACE}
If the optional CA certificate is needed, run the following command:
oc create secret generic keycloak-custom-tls-secret --from-file=ca.crt=ca.crt --from-file=tls.crt=tls.crt --from-file=tls.key=tls.key -n ${KEYCLOAK_NAMESPACE}
To apply the configuration changes, restart the
operand-deployment-lifecycle-manager
pod in your operator namespace:oc delete pods -l app.kubernetes.io/instance=operand-deployment-lifecycle-manager -n <operator namespace>
Adding certificates to the Keycloak trust store
You can add certificates to the Keycloak trust store so that Keycloak securely connects to services protected by a custom certificate authority.
To add certificates to the Keycloak trust store, you must be a user with namespace admin permissions. For more information, see OpenShift roles and permissions.
Identify the namespace that contains Keycloak. For installations using A specific namespace on the cluster mode, this is the same namespace where your instances are deployed. For installations using All namespaces on the cluster mode, this is the
servicesNamespace
defined in theCommonService
resource (which isibm-common-services
by default).Set this namespace as an environment variable to use in further commands:
KEYCLOAK_NAMESPACE=<namespace>
Create a configmap named
cs-keycloak-ca-certs
with your additional certificates. Use one key for each certificate:oc create configmap cs-keycloak-ca-certs --from-file=cert1.pem --from-file=cert2.pem -n ${KEYCLOAK_NAMESPACE}
To apply the configuration changes, restart the
cs-keycloak
pods:oc rollout restart statefulset/cs-keycloak
Deployment size profiles
By default, Keycloak and the Cloud Native PostgreSQL instances are deployed with the starterset
sizing profile. To configure the size of your Keycloak installation, update the CommonService
custom resource to use a different profile. For more information, including advanced configuration, see Configuring the Cloud Pak foundational services.
Advanced Keycloak administration
Log into the OpenShift web console as an administrator.
Get the login credentials from the Keycloak secret.
In the navigation pane, click Workloads > Secrets.
From the Project dropdown, select the namespace that contains the Keycloak secret, which is named
cs-keycloak-initial-admin
:For installations that use A specific namespace on the cluster mode, the secret is in the same namespace as your deployed instances.
For installations that use All namespaces on the cluster mode, the secret is in the
servicesNamespace
(ibm-common-services
by default) that is defined in theCommonService
resource. For more information, see OpenShift roles and permissions.
- From the Data section of the secret, copy the username and the Keycloak administrator password.Attention:
- If you change the password for this Keycloak administrator user in the Keycloak UI, you must also update the password value in the cs-keycloak-initial-admin secret. If you do not update the password, the IBM Cloud Pak for Integration operator cannot function and instances with user interfaces have errors.
- As stated before, do not use this Keycloak administrator password for identity and access management. The Keycloak administrator is an advanced admin user that is used by the IBM Cloud Pak for Integration operator.
Get the URL for logging in to the Keycloak Administrator console.
In the navigation pane, click Networking > Routes.
From the Project dropdown, select the namespace that contains the Keycloak route:
For installations that use A single namespace on the cluster mode, this is the namespace in which your instances are deployed.
For installations that use All namespaces on the cluster mode, this is the
servicesNamespace
(namedibm-common-services
by default) that is defined in theCommonService
resource.
Copy the Keycloak URL, for example,
https://keycloak-ibm-common-services.apps.ibm.com
.
Paste the Keycloak URL in your browser to access the Keycloak Administrator console.
Log in to the Administrator console by using the login credentials (username and password) from step 2.
Change the realm setting from the default (master) to cloudpak by using the realm selector dropdown.
You can now manage advanced realm configuration.