# Keycloak

This article provides a detailed guide to integrate the OvalEdge application with **Keycloak** using **SAML-based Single Sign-On (SSO)**. Keycloak acts as the centralized Identity Provider (IdP) for managing user authentication and authorization. While Keycloak handles authentication, OvalEdge continues to manage application-level permissions and role mappings internally.

### Purpose

The objectives of this integration are to:

* Enable secure SSO authentication for OvalEdge users through Keycloak.
* Implement centralized access control using Keycloak IdP configurations.
* Streamline user and group management via Keycloak realms, clients, roles, and groups.
* Enhance security by externalizing authentication and minimizing credential management within OvalEdge.

### Process Overview

This guide covers the following steps:

* Create and configure a new Keycloak realm for OvalEdge.
* Register OvalEdge as a **SAML client** in Keycloak.
* Configure client scopes and mappers to pass user attributes in SAML assertions.
* Create users, roles, and groups in Keycloak.
* Configure the OvalEdge application with Keycloak SAML metadata.
* Restart Tomcat services and validate SSO login.

### Prerequisites

* Access to the **Keycloak Admin Console**.
* Administrator credentials for Keycloak.
* OvalEdge application URL.
* Access to the OvalEdge application server (VM).
* Access to Tomcat directory and environment configuration files.

## Step-by-Step Configuration

### Login to Keycloak

* Open the Keycloak Admin Console in a browser.
* Log in using administrator credentials.

  <figure><img src="/files/I95Uv4mrvf2i8Z7Lp4uB" alt=""><figcaption></figcaption></figure>

### Create a Realm

* In the Admin Console, click **Create Realm**.

  <figure><img src="/files/7KlOLMF6gRBKCwu5jx2V" alt=""><figcaption></figcaption></figure>
* Enter a realm name (e.g., `OvalEdgeRealm`).

  <figure><img src="/files/WeFbcAdAmloPJCVozWQF" alt=""><figcaption></figcaption></figure>
* Click **Create**.

### Switch to the Realm

* Use the dropdown in the top-left corner to switch to the newly created realm.

  <figure><img src="/files/18ypPwYvgbCT54I63IzK" alt=""><figcaption></figcaption></figure>

### Create a Client

* In the left menu, navigate to **Clients** .

  <figure><img src="/files/YgJDx28AROgBAe2EArCA" alt=""><figcaption></figcaption></figure>
* **Create Client**.

  <figure><img src="/files/vVRluEfVkiEudJDxAJJw" alt=""><figcaption></figcaption></figure>
* Configure as follows:
  * **Client Type:** SAML
  * **Client ID:** `http://<DNS or IP of OE App>/saml/metadata`
  * **Name:** OvalEdgeSAMLClient
* Click **Next** → **Save**.

### Configure Client Settings

* Go to **Clients → select newly created \[Client ID]**.

  <figure><img src="/files/X1wXn1MirHhR23oSpQxf" alt=""><figcaption></figcaption></figure>
* Under General Settings, keep the Client ID unchanged.

  <figure><img src="/files/mMxpfmOYAlVGrLJyXjH0" alt=""><figcaption></figcaption></figure>
* Under **Access Settings,** set **Valid Redirect URI** to:

  ```
  http://<DNS or IP of OE App>/ovaledge/saml/SSO
  ```

  <figure><img src="/files/8Nnwhxe93CtsGbHdcZpB" alt=""><figcaption></figcaption></figure>
* Click **Save**.

### Configure Keys

* Go to the **Keys** tab.

  <figure><img src="/files/j4j8NkRCXtH7OdjcDXoR" alt=""><figcaption></figcaption></figure>
* Disable **Keys Signature Required**.
* Save changes if prompted.

### Create Roles

* Navigate to **Roles → Add Role**.

  <figure><img src="/files/lNmett3Jofj4pL5fsmNA" alt=""><figcaption></figcaption></figure>
* Create the following roles:
  * OE\_ADMIN
  * OE\_PUBLIC

### Configure Client Scopes and Mappers

* Go to **Client Scopes → Assigned Client Scopes.**

  <figure><img src="/files/YMmXlt0hxiEbRsrQBW6Q" alt=""><figcaption></figcaption></figure>
* **Click on Add predefined mapper**.

  <figure><img src="/files/LbsNFev43K4ENCisqbYs" alt=""><figcaption></figcaption></figure>
* Select and configure the following:
  * X500 Username
  * Role List
  * X500 Email
  * X500 givenName

    <figure><img src="/files/mu5T6dhpkgNZwPtK6wCC" alt=""><figcaption></figcaption></figure>
* Configure each mapper as per requirements (refer to UI screenshots for settings).
  * X500 Username

    <figure><img src="/files/FUfiVtsjBGuTMaxIeKdx" alt=""><figcaption></figcaption></figure>
  * Role List

    <figure><img src="/files/axn2dlKORRTiAsA729Uz" alt=""><figcaption></figcaption></figure>
  * X500 Email

    <figure><img src="/files/fzlcToFZ8sO8Cr8SNdfv" alt=""><figcaption></figcaption></figure>
  * X500 givenName

    <figure><img src="/files/lDNuLHn1JiKgnfnkQecK" alt=""><figcaption></figcaption></figure>

### Configure Assertion Consumer URLs

* Open the **Advanced** tab of the client configuration.

  <figure><img src="/files/FzJm8EfAwcdfYm8kSc3R" alt=""><figcaption></figcaption></figure>
* Set URLs:
  * **Assertion Consumer Service POST Binding:**

    ```
    http://<OE App IP>:8080/ovaledge/saml/SSO
    ```
  * **Assertion Consumer Redirect Binding:**

    ```
    http://<OE App IP>:8080/ovaledge/saml/SSO
    ```
* Click **Save**.

### Create Users

* Navigate to **Users → Add User**.

  <figure><img src="/files/KyMNyaPI13IpB8F1wJw9" alt=""><figcaption></figcaption></figure>
* Enter user details → **Create**.

  <figure><img src="/files/aaziUZCFlmjnPyMZMdsa" alt=""><figcaption></figcaption></figure>
* **After creation:**
  * Go to **Credentials** tab.

    <figure><img src="/files/I8pIRQFaGXIwtQ9uhBbl" alt=""><figcaption></figcaption></figure>
  * Set and save a password.

    <figure><img src="/files/mdFkCLxRHZQhGJWjzIZd" alt=""><figcaption></figcaption></figure>
  * Go to **Role Mappings** → Assign role.

    <figure><img src="/files/sfV9mY208WMPZXHKT8gs" alt=""><figcaption></figcaption></figure>
  * Assign the user to `OE_ADMIN` or `OE_PUBLIC` role.

    <figure><img src="/files/K8CsrzFcTlXbWPudhI5F" alt=""><figcaption></figcaption></figure>

### Create Groups

* Navigate to **Groups → Create Group**.

  <figure><img src="/files/DoYOcQWxw1qRG11KaGmz" alt=""><figcaption></figcaption></figure>
* Enter group name (e.g., OE\_ADMIN) → **Save**.<br>

  <figure><img src="/files/hb6BK7e7w13Yo9csWxmC" alt=""><figcaption></figcaption></figure>
* Open the created group.

  <figure><img src="/files/R11BwBIxTIkIttesoPR7" alt=""><figcaption></figcaption></figure>
* **Members** tab → Add users to the group.

  <figure><img src="/files/8KzYEb6zyxq2cvpOkD0w" alt=""><figcaption></figcaption></figure>

### Configure Realm Settings

* Navigate to **Realm Settings**.

  <figure><img src="/files/V8Srz9PPDIuZbgqUVyu2" alt=""><figcaption></figcaption></figure>
* Copy the **SAML Metadata URL**.
* Set **Require SSL** to `none`.

  <figure><img src="/files/10RPXPKH0xfJTHYpb64X" alt=""><figcaption></figcaption></figure>
* Save the metadata URL for later use.

### Modify OvalEdge Configuration

**A. Edit `oasis.properties`**

* Go to the OvalEdge application VM → `extprop` directory.
* Open `oasis.properties` and update:

  ```
  saml.metadata.url = <copied-metadata-url>
  entityBaseURL = http://<OE App IP>:8080/ovaledge
  ```

  <figure><img src="/files/bjBMyp7KVrqR4Ylfp1GG" alt=""><figcaption></figcaption></figure>
* Save the file.

**B. Update Tomcat Environment**

**For Linux:**

* Edit `setenv.sh` in Tomcat bin directory.
* Add:

  ```
  -DOVALEDGE_SECURITY_TYPE=saml
  ```

  <figure><img src="/files/2eQFUM3RYZEk8jyRfFZ5" alt=""><figcaption></figcaption></figure>
* Save and close.

**For Windows:**

* Open `tomcat9w.exe`.
* Go to **Java** tab.
* Add:

  ```
  -DOVALEDGE_SECURITY_TYPE=saml
  ```

  <div align="left"><figure><img src="/files/Vh0OzZT2OJs9LuTX0zpx" alt=""><figcaption></figcaption></figure></div>
* Click **Apply** and **OK**.

### Restart Tomcat and Validate Integration

* Restart Tomcat service.
* Wait 2–3 minutes.
* Open the OvalEdge application URL in a browser.

  <figure><img src="/files/y8zG1PIsa0lZ6MKqG2Du" alt=""><figcaption></figcaption></figure>
* Click **Login** → Enter Keycloak user credentials.

  <figure><img src="/files/bsl4u79ZSjmNqVyjnUmX" alt=""><figcaption></figcaption></figure>
* Confirm that authentication redirects and successfully logs into OvalEdge via SSO.

  <figure><img src="/files/kKZeiZ0zCes9NCiw7zs0" alt=""><figcaption></figcaption></figure>

***

Copyright © 2025, OvalEdge LLC, Peachtree Corners, GA, USA.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ovaledge.com/release8.1/installation-and-settings/authentication-and-sso-setup/keycloak.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
