Change2Twin Keycloak Documentation

What is Keycloak?

Keycloak is a robust, open-source identity and access management (IAM) platform designed to provide seamless authentication, authorization, and single sign-on (SSO) for a wide range of applications. Developed to support modern security standards like OAuth 2.0, OpenID Connect, and SAML, Keycloak enables organizations to integrate with various identity providers, including Google, LDAP, Active Directory, and social identity providers such as GitHub or Facebook. This flexibility makes Keycloak an ideal choice for both enterprise environments and cloud-native applications, where managing identity across multiple services is critical.

One of Keycloak's standout features is its built-in user federation capability, allowing organizations to connect to existing user directories, eliminating the need for users to manage multiple accounts across services. Additionally, Keycloak offers multi-factor authentication (MFA), further strengthening security by requiring users to authenticate through additional verification methods like OTP (one-time passwords) or hardware tokens.

Keycloak's powerful authorization services enable fine-grained access control, supporting RBAC (Role-Based Access Control) and ABAC (Attribute-Based Access Control) policies, which provide granular control over user permissions and resource access. Its flexible admin console and RESTful API allow administrators to efficiently manage users, roles, permissions, and session configurations, ensuring smooth scaling as systems grow in complexity.

For developers, Keycloak simplifies secure application development by offering easy-to-integrate adapters for popular frameworks like Spring Boot, Node.js, and Java EE, as well as client libraries for other languages. This allows quick integration of Keycloak’s authentication and authorization mechanisms into existing software, reducing the time and effort required to build custom security solutions.

By handling all the complexities of user sessions, login workflows, identity brokering, and account management, Keycloak greatly reduces the burden on development teams. Its support for social login, single sign-out, identity brokering, and customizable user interfaces ensures a cohesive and consistent user experience across all connected applications. Whether deployed in on-premise environments or cloud infrastructures like Kubernetes, Keycloak provides a scalable and secure platform for centralized identity management across diverse ecosystems.

In short, Keycloak simplifies the implementation of modern security protocols while enhancing the user experience and easing the burden of managing identity in distributed, multi-application environments.

Why Use Keycloak in Change2Twin?

In the context of Change2Twin, Keycloak streamlins identity and access management for users interacting with the platform. Here are the key reasons for choosing Keycloak:

Downloading Keycloak

To get started with Keycloak, you can download it from the official Keycloak Downloads page. Keycloak can be deployed in various environments, including as a standalone server or through containerized environments such as Docker or Kubernetes, making it flexible for different infrastructure needs.

Middleware Client for Change2Twin

The middleware client is a pre-configured client designed to integrate with the Keycloak identity management system specifically for the Change2Twin platform. This client is configured using a middleware.json file, which contains all the necessary settings for establishing secure communication between Change2Twin applications and Keycloak.

The middleware client supports two primary authentication methods, making it suitable for various use cases:

Key Roles within the Middleware Client

The middleware client employs a role-based access control (RBAC) system to regulate user permissions and ensure secure access across the Change2Twin platform. These roles define the scope of actions that a user can perform within the system and must be carefully assigned based on the individual's responsibilities and required level of access. The RBAC structure is essential for maintaining the platform's security and efficient resource management.

The following predefined roles form the core of the RBAC system and ensure the platform's proper functioning:

The RBAC system implemented by the middleware client ensures that users at different levels—from everyday users to high-level administrators—have the appropriate level of access to the platform. This division of roles allows for flexible, secure interactions while minimizing the risk of unauthorized access to sensitive data. Each role is carefully tailored to fit the responsibilities and needs of its assigned user, ensuring a clear, well-defined structure of control across the system.

This well-structured approach to access control makes the Change2Twin platform not only secure but also scalable, allowing it to accommodate a growing number of users while maintaining a high level of security. By aligning user permissions with specific roles, the platform can adapt to various user types, from general marketplace participants to system administrators, without compromising on performance or security.

Importing Middleware client

1. Log in to the Keycloak Admin Console

Open your browser and navigate to the URL of your Keycloak Admin Console, typically:

http://<your-keycloak-server>/admin

Enter your administrator username and password to log in.

2. Select Your Realm

After logging in, choose the appropriate Realm where you want to import the client. A realm is a logical grouping of resources in Keycloak (users, roles, clients, etc.).

If you are importing the client into an existing realm, select it from the dropdown at the top-left corner. Otherwise, click Add Realm to create a new one.

3. Navigate to the Clients Section

From the left-hand menu, click on Clients. This will display the list of clients configured for the selected realm.

4. Import the Client Configuration

Click the Import client button to start the process of adding a new client. This will present the option to manually configure a client or import one from a file.

Click the Browse... button. A file dialog will open, allowing you to select a configuration file like the pre-configured middleware.json file.

5. Review the Imported Configuration

Once the file is uploaded, Keycloak will automatically populate the client settings based on the configuration. Review the imported values, which may include:

6. Save the Imported Client

Once you have reviewed the settings, click Save to finish importing the client into your Keycloak realm.

7. Configure Roles

If roles need to be configured for the client:

8. Test the Client Integration

After importing the client and configuring roles, test the integration by: