# Keycloak Using OIDC

This article provides step-by-step instructions to integrate the OvalEdge application with Keycloak using OpenID Connect (OIDC)-based Single Sign-On (SSO). The integration enables centralized authentication through Keycloak while OvalEdge continues to manage internal access control.

### Purpose

The objectives of this guide are to:

* Enable secure OIDC-based SSO authentication for OvalEdge users.
* Centralize identity and access management using Keycloak as the Identity Provider (IdP).
* Simplify user provisioning and implement role-based access control.

### Process Overview

This guide covers the following high-level steps:

1. Access the Keycloak Admin Console.
2. Create a new Realm.
3. Register OvalEdge as an OIDC Client.
4. Configure client credentials and redirect URIs.
5. Create roles and users.
6. Assign roles to users.
7. Configure client scopes and mappers.
8. Retrieve OpenID Endpoint Configuration.
9. Update OvalEdge configuration files.
10. Restart services and verify authentication.

### Prerequisites

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

## Steps

### Access the Keycloak Admin Console

* Open the Keycloak Admin Console in a browser.
* Log in using valid administrator credentials.
* Use the Realm dropdown to view and manage realms.

### Create a New Realm

* Click **Create Realm**.
* Enter a unique name for the new realm.
* Click **Create**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FntXJnF5RE08gj1Bd4NMR%2Fimage.png?alt=media&#x26;token=8839d624-584c-44ad-96f6-797ef47b4d55" alt=""><figcaption></figcaption></figure>
* Confirm the realm appears in the Realm dropdown.\
  ![](https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FZ3chXXnCx53TZ487i31l%2Fimage.png?alt=media\&token=72c6e174-e88a-42e7-9887-03eb14badd05)

### Configure a Client for OvalEdge

* Select the newly created realm.
* Navigate to **Clients** and click **Create Client**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Fl3GDKZ1pbaW0fz7V0pJD%2Fimage.png?alt=media&#x26;token=264ed4b7-39c5-4cae-a0b9-df7772229cf1" alt=""><figcaption></figcaption></figure>
* Enter the following details:
  * Client Type: **OpenID Connect**
  * Client ID: `oe-keycloak` (example; use a meaningful identifier)
  * Name and Description: Provide descriptive names.

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FMaPipZdxtTQHtZG7FA9u%2Fimage.png?alt=media&#x26;token=35522d59-dfd9-4127-93fa-61e3f1dee071" alt=""><figcaption></figcaption></figure>
* Click **Next**.

**Capability Config:**

* Enable **Client Authentication**.
* Set Authentication Flow to **Standard Flow**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F8jq8hsnnpLj9Hi0xTStX%2Fimage.png?alt=media&#x26;token=ee24b8f9-81a7-4cff-a58f-bded39933e0e" alt=""><figcaption></figcaption></figure>
* Click **Next**.

**Login Settings:**

* Root URL: `https://client.ovaledge.com/ovaledge`
* Home URL: `https://client.ovaledge.com/ovaledge`
* Redirect URIs:\
  `https://client.ovaledge.com/ovaledge/oauth2/code/keycloak`

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FhHC1rkTZjiRRr1xxmL0l%2Fimage.png?alt=media&#x26;token=ee395dc3-facc-4d86-a5e8-73079a2552f3" alt=""><figcaption></figcaption></figure>

> Note:
>
> * Do not include `/login` at the end of the URL.
> * Replace `client.ovaledge.com` with the actual domain.
> * Use only specific redirect URIs for security.

* Click **Save** to complete client creation.

### Manage Client Credentials

* Navigate to **Clients** and select the created Client ID.
* Go to the **Credentials** tab.
* Set **Client ID and Secret** as the Client Authenticator.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FfCuwRXrdI5PyB3z2eYuf%2Fimage.png?alt=media&#x26;token=be4b9cdd-d36b-4b4c-b4eb-aec4397309ef" alt=""><figcaption></figcaption></figure>
* Click **Save** to generate the client secret.
* Record the generated Client Secret for later use.

### Create Roles

* Navigate to the **Roles** tab.
* Click **Create Role**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FbzWANFavFdt5CGgZA64t%2Fimage.png?alt=media&#x26;token=a038e34f-f360-40b1-8b14-450ee53cffb0" alt=""><figcaption></figcaption></figure>
* Enter the role name (e.g., `OE_ADMIN`).
* Optionally add a description.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FYPEDsSzYyM6l270sUmBh%2Fimage.png?alt=media&#x26;token=8ddd5006-2bdd-4a1d-8d41-bf66df4c216e" alt=""><figcaption></figcaption></figure>
* Click **Save**.

### Create Users and Assign Roles

* Navigate to **Users** and click **Add User**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FfDbbVmMo5SBtaLls0Wxv%2Fimage.png?alt=media&#x26;token=e1b9f981-8a5d-4e5d-b9d4-8454ccd9c5a7" alt=""><figcaption></figcaption></figure>
* Fill in the required details and click **Create**.
* Open the created username to access User Details.
* Go to the **Role Mappings** tab.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F67NYfZBn1SwcAez6lyw8%2Fimage.png?alt=media&#x26;token=ac3ffa6f-8626-4d6c-bee9-8ac02a799863" alt=""><figcaption></figcaption></figure>
* In **Client Roles**, select the relevant client.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FEg4BuDUHnpKNq1FvLzZK%2Fimage.png?alt=media&#x26;token=daafa6c5-e5ea-4364-b5cd-bb11d975c550" alt=""><figcaption></figcaption></figure>
* Assign the created role (e.g., `OE_ADMIN`) and click **Assign**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FwfMmTnfeWM8TeQ3PAzOG%2Fimage.png?alt=media&#x26;token=baaea988-7d55-4fc7-8c5b-507f271c9b69" alt=""><figcaption></figcaption></figure>

### Configure Client Scopes

* Navigate to **Client Scopes**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FkEeHPRNO3NxDCjkQAOym%2Fimage.png?alt=media&#x26;token=a26a1c2f-eccd-4200-8cb9-15ccdbd1b98a" alt=""><figcaption></figcaption></figure>
* Select the predefined **Roles** client scope.
* In **Settings**:
  * Enable **Include in token scope**.
  * Ensure **First Name, Last Name, and Email Address** are included.

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FPnrZFoacvMFA2Nybx4hb%2Fimage.png?alt=media&#x26;token=5ec5884f-45da-4d83-bbd3-71d5b2461899" alt=""><figcaption></figcaption></figure>
* Click **Save**.

### Enable Client Role Mappers

* Navigate to the **Mappers** tab.
* Select or create role mappers for the client.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F8nKDTekTYbnQzLiVYRT0%2Fimage.png?alt=media&#x26;token=5200d6fd-2918-4281-aa73-e09542b16c1c" alt=""><figcaption></figcaption></figure>
* Set **Client ID** to `oe-keycloak`.
* Enable **Add to ID token** for relevant mappers.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FU4HXMhtzQpRWINXLbIxt%2Fimage.png?alt=media&#x26;token=2d347448-f0da-40e1-ad8b-b9feb960e1fa" alt=""><figcaption></figcaption></figure>
* Save the configuration.

### Obtain OpenID Endpoint Configuration

* Navigate to **Realm Settings**.
* Under the **Endpoints** tab, click **OpenID Endpoint Configuration**.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FgR6xWj8KDjcz9sts9Kx9%2Fimage.png?alt=media&#x26;token=6e8d6321-edcc-4146-b4a6-b822d092bb87" alt=""><figcaption></figcaption></figure>
* Copy the base URL up to `/openid-connect`.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FhkIU07Y24BIBnJQ3BcuT%2Fimage.png?alt=media&#x26;token=329d9828-bd2f-41f2-ad8b-e85645fadcee" alt=""><figcaption></figcaption></figure>
* Save this URL for OvalEdge configuration.

### Configure OvalEdge

* Log in to the OvalEdge Application VM.
* Open the `oasis.properties` file in the **extprop** folder.
* Update or add the following values:
  * **Client ID:** from Keycloak client setup.
  * **Client Secret:** from Keycloak client credentials.
  * **OIDC base URL:** from the OpenID Endpoint Configuration.

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FtdxXQsM10Bo2oBXEYjgp%2Fimage.png?alt=media&#x26;token=261d4138-ceff-4ccf-b47d-8b4d46d0b8e9" alt=""><figcaption></figcaption></figure>
* Save and close the file.

**Tomcat Configuration:**

* Navigate to the Tomcat **bin** folder.

For Linux:

* Edit `setenv.sh`.
* Add:

  ```
  -DOVALEDGE_SECURITY_TYPE=oauth2
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FhiztXYaKAcTCif1jg17R%2Fimage.png?alt=media&#x26;token=d9184f55-a186-42e5-a756-b3dc5f34bf82" alt=""><figcaption></figcaption></figure>
* Save and close the file.

For Windows:

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

  ```
  -DOVALEDGE_SECURITY_TYPE=oauth2
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FSiEOZ4RFkqufnkZKDaI9%2Fimage.png?alt=media&#x26;token=b7df6d41-1573-4d0f-b8cc-3ca829e87932" alt=""><figcaption></figcaption></figure>
* Click **Apply** and **OK**.

**Restart Services:**

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

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FpyokTNxl1FwIXyAJPIuR%2Fimage.png?alt=media&#x26;token=24e4d37e-30ad-44ff-83e7-7a369863da87" alt=""><figcaption></figcaption></figure>

**Validate Integration:**

* Click **Login with Keycloak**.
* Enter the Keycloak username and password.

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FNgNeqsjnBzAUbrnIRjh1%2Fimage.png?alt=media&#x26;token=24657058-2757-4a94-9795-7166c79efad4" alt=""><figcaption></figcaption></figure>
* Upon successful authentication, it will be redirected to the OvalEdge home page.&#x20;

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FxfV1c5zN56FV97tJIgqf%2Fimage.png?alt=media&#x26;token=aa4afa0e-fa74-4c57-8035-6d930dc2ce53" alt=""><figcaption></figcaption></figure>

***

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