> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Keycloak SSO for Docker

# Keycloak SSO for Docker

To enable security for the Docker deployment, follow the next steps:

## 1. Create an .env file

Create an `openmetadata_keycloak.env` file and add the following contents as an example. Use the information
generated when setting up the account.

Check the more information about environment variable [here](/v1.12.x/deployment/security/configuration-parameters).

<Tabs>
  <Tab title="implicit">
    ```
    # Implicit Flow
    AUTHORIZER_CLASS_NAME= org.openmetadata.service.security.DefaultAuthorizer
    AUTHORIZER_REQUEST_FILTER= org.openmetadata.service.security.JwtFilter
    AUTHORIZER_ADMIN_PRINCIPALS=[admin]                 # john.doe from john.doe@example.com
    AUTHORIZER_PRINCIPAL_DOMAIN=open-metadata.org       # Update with your Domain,The primary domain for the organization (example.com from john.doe@example.com).

    AUTHENTICATION_PROVIDER=custom-oidc                 # Use "custom-oidc" for Keycloak
    AUTHENTICATION_CLIENT_ID=testsso
    CUSTOM_OIDC_AUTHENTICATION_PROVIDER_NAME=KeyCloak   # Name of the OIDC provider
    AUTHENTICATION_PUBLIC_KEYS=[http://localhost:8081/auth/realms/data-sec/protocol/openid-connect/certs, https://{your domain}/api/v1/system/config/jwks]                                 # Update with your Domain and Make sure this "/api/v1/system/config/jwks" is always configured to enable JWT tokens
    AUTHENTICATION_CALLBACK_URL="http://localhost:8585/callback"
    AUTHENTICATION_AUTHORITY={http://localhost:8080/realms/{your-realm}}
    AUTHENTICATION_CLIENT_TYPE=public
    ```
  </Tab>

  <Tab title="authcode">
    ```
    # Auth Code Flow
    AUTHORIZER_CLASS_NAME= org.openmetadata.service.security.DefaultAuthorizer
    AUTHORIZER_REQUEST_FILTER= org.openmetadata.service.security.JwtFilter
    AUTHORIZER_ADMIN_PRINCIPALS=[admin]                 # john.doe from john.doe@example.com
    AUTHORIZER_PRINCIPAL_DOMAIN=open-metadata.org       # Update with your Domain,The primary domain for the organization (example.com from john.doe@example.com).

    AUTHENTICATION_PROVIDER=custom-oidc                 # Use "custom-oidc" for Keycloak
    CUSTOM_OIDC_AUTHENTICATION_PROVIDER_NAME=KeyCloak   # Name of the OIDC provider
    AUTHENTICATION_PUBLIC_KEYS=[http://localhost:8081/auth/realms/data-sec/protocol/openid-connect/certs, https://{your domain}/api/v1/system/config/jwks]                                 # Update with your Domain and Make sure this "/api/v1/system/config/jwks" is always configured to enable JWT tokens
    AUTHENTICATION_AUTHORITY={http://localhost:8081/auth/realms/data-sec}
    AUTHENTICATION_CLIENT_ID=testsso
    AUTHENTICATION_CALLBACK_URL="https://{your domain}/callback"
    AUTHENTICATION_CLIENT_TYPE=confidential

    OIDC_CLIENT_ID=testsso                             # Replace with your Keycloak client ID
    OIDC_CLIENT_SECRET="{CLIENT_SECRET}"               # Replace with your Keycloak client secret
    OIDC_TYPE="Keycloak"                               # Specify the OIDC provider (Keycloak)
    OIDC_DISCOVERY_URI="OIDC_DISCOVERY_URI=http://host.docker.internal:8081/realms/openmetadata/.well-known/openid-configuration"                              # Keycloak's discovery URI Update your Keycloak's Domain and Realm
    OIDC_CALLBACK="http://localhost:8585/callback"     # Callback URL registered in Keycloak
    OIDC_SERVER_URL="http://localhost:8585"            # OpenMetadata server URL
    ```
  </Tab>
</Tabs>

<Tip>
  Altering the order of claims in `jwtPrincipalClaims` may lead to problems when matching a user from a token with an existing user in the system. The mapping process relies on the specific order of claims, so changing it can result in inconsistencies or authentication failures, as the system cannot ensure correct user mapping with a new claim order.
</Tip>

## 2. Start Docker

```commandline theme={null}
docker compose --env-file ~/openmetadata_keycloak.env up -d
```

## Configure Ingestion

Once your server security is set, it's time to review the ingestion configuration. Our bots support JWT tokens
to authenticate to the server when sending requests.

Find more information on [**Enabling JWT Tokens**](/deployment/security/enable-jwt-tokens) and [**JWT Troubleshooting**](/deployment/security/jwt-troubleshooting) to ensure seamless authentication.

<CardGroup cols={1}>
  <Card title="KeyCloak" href="/v1.12.x/deployment/security/keycloak">
    Go to KeyCloak Configuration
  </Card>
</CardGroup>
