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

# Keycloak SAML setup

> Configure SAML-based single sign-on between Keycloak and CodeRabbit for your Enterprise organization.

export const EnterprisePlanBadge = ({tip = "This feature is available exclusively as part of the Enterprise plan. Please refer to our pricing page for more information about our plans and features.", title = "Enterprise Plan", cta = "Read more", href = "https://coderabbit.ai/pricing", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="building-2" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

export const AdminRoleBadge = ({tip = "This feature requires an organization owner, an admin role or the corresponding permission. Regular Members do not have access.", title = "Admin Only", cta = "View roles", href = "/management/roles", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="lock" color="orange" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

<EnterprisePlanBadge />

<AdminRoleBadge tip="This page requires an admin role. Members do not have access to Enterprise SSO settings." />

Use this guide to configure Keycloak as the identity provider for CodeRabbit. The current setup is support-assisted: you create the Keycloak SAML client, collect the required metadata, and then send the final values to CodeRabbit for enablement.

## Before you start

Make sure you have:

* A running **Keycloak** instance and access to its **admin console**
* A **realm** to host the CodeRabbit SAML client
* The email domain that should authenticate through CodeRabbit
* A way to reach your account team to request CodeRabbit's service provider values and submit your final metadata

Your Keycloak realm descriptor URL must be reachable from CodeRabbit so we can fetch the IdP metadata automatically. If your Keycloak is only accessible on an internal network, see [What CodeRabbit needs from you](#what-coderabbit-needs-from-you) for the file-upload alternative.

## What CodeRabbit provides

Before you configure the Keycloak client, reach out to your account team to request these values:

* **Assertion Consumer Service (ACS) URL**
* **SP Entity ID**

Keycloak requires both values to create the SAML client.

## What CodeRabbit needs from you

After you configure the Keycloak client, send these items to CodeRabbit:

* **Email domain**: for example, `yourcompany.com`
* **IdP metadata**, in one of these forms (listed in order of preference):
  * **Metadata URL**: the realm SAML descriptor URL — `https://<keycloak-host>/realms/<realm-name>/protocol/saml/descriptor`
  * **Metadata XML file**: download the XML from the URL above and attach it — use this if your Keycloak is not reachable from the public internet
  * **Manual values**, if neither of the above is possible:
    * **Sign-on URL**: the `Location` attribute of the `HTTP-POST` `SingleSignOnService` element in the descriptor
    * **Issuer**: the `entityID` attribute of the `EntityDescriptor` element (typically `https://<keycloak-host>/realms/<realm-name>`)
    * **Signing certificate**: the contents of `ds:X509Certificate`, saved as a `.pem` file

## Set up the Keycloak SAML client

<Steps>
  <Step title="Create the SAML client">
    Sign in to the Keycloak admin console, switch into the realm you want to use, then go to **Clients** -> **Create client**.

    On the **General Settings** screen:

    * **Client type**: `SAML`
    * **Client ID**: paste the **SP Entity ID** provided by CodeRabbit
    * **Name**: `CodeRabbit` (display-only)

    <Frame caption="Create the SAML client and set the Client ID to CodeRabbit's SP Entity ID">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-create-client-general-settings.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=54244ce437d64eec02837d0c34847316" alt="Keycloak Create client General Settings screen with SAML selected and Client ID filled in" width="2124" height="1454" data-path="assets/images/keycloak-create-client-general-settings.png" />
    </Frame>

    Click **Next**. On the **Login Settings** screen:

    * **Valid redirect URIs**: paste CodeRabbit's **ACS URL**
    * **Master SAML Processing URL**: paste the **same ACS URL**
    * Leave the remaining fields blank.

    <Frame caption="Paste the ACS URL into both Valid redirect URIs and Master SAML Processing URL">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-create-client-login-settings.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=fee8c58173261010627155cf4bce8e3c" alt="Keycloak Create client Login Settings screen with the ACS URL in both the Valid redirect URIs and Master SAML Processing URL fields" width="1052" height="785" data-path="assets/images/keycloak-create-client-login-settings.png" />
    </Frame>

    Click **Save**. You land on the client's Settings tab.
  </Step>

  <Step title="Tune the SAML settings">
    On the client's **Settings** tab, set the following values. Defaults for unlisted fields are fine.

    **SAML capabilities**

    | Field                  | Value   |
    | ---------------------- | ------- |
    | Name ID format         | `email` |
    | Force name ID format   | On      |
    | Force POST binding     | On      |
    | Include AuthnStatement | On      |

    <Frame caption="Set the SAML Capabilities section on the client Settings tab">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-client-saml-settings-part1.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=c3fdf5babfb1b2f5d50399c96051fd84" alt="Keycloak client SAML Capabilities section configured with email Name ID format, Force POST binding On, and Include AuthnStatement On" width="1290" height="596" data-path="assets/images/keycloak-client-saml-settings-part1.png" />
    </Frame>

    **Signature and Encryption**

    | Field               | Value        |
    | ------------------- | ------------ |
    | Sign documents      | On           |
    | Sign assertions     | On           |
    | Signature algorithm | `RSA_SHA256` |

    <Frame caption="Set the Signature and Encryption section on the same tab">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-client-saml-settings-part2.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=887a6df0cb6b1ebe93a6825cc1ee7075" alt="Keycloak client Signature and Encryption section with Sign Documents and Sign Assertions both On and Signature algorithm set to RSA_SHA256" width="1026" height="554" data-path="assets/images/keycloak-client-saml-settings-part2.png" />
    </Frame>

    Switch to the **Keys** tab and turn **Client signature required** **Off**.

    <Warning>
      This setting is required. CodeRabbit does not sign outgoing AuthnRequests — leaving **Client signature required** On causes Keycloak to reject the request with `invalid_signature` and blocks the sign-in flow entirely.
    </Warning>

    <Frame caption="Turn Client signature required Off on the Keys tab">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-client-keys-signature-off.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=f44e3e537e390f20b442731015529240" alt="Keycloak client Keys tab with Client signature required toggled Off" width="1032" height="728" data-path="assets/images/keycloak-client-keys-signature-off.png" />
    </Frame>

    Save each change.
  </Step>

  <Step title="Add attribute mappers">
    CodeRabbit expects email, first name, and last name to be present in the SAML assertion under specific attribute names. Add three mappers so the assertion includes them.

    Open the client -> **Client scopes** tab -> click the row whose name ends in `-dedicated` (the dedicated client scope) -> switch to the **Mappers** tab.

    Click **Configure a new mapper** -> **By configuration** -> **User Property**. Add one mapper per row:

    | User Property | SAML Attribute Name | SAML Attribute NameFormat | Friendly Name |
    | ------------- | ------------------- | ------------------------- | ------------- |
    | `email`       | `mail`              | `Basic`                   | Email         |
    | `firstName`   | `firstName`         | `Basic`                   | First name    |
    | `lastName`    | `lastName`          | `Basic`                   | Last name     |

    The **SAML Attribute Name** column is what CodeRabbit reads from the assertion — the values must match the table exactly, including the `mail` spelling for email.

    <Frame caption="Three User Property mappers added to the dedicated client scope">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-client-attribute-mappers.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=3e0204e6bce6150631cd590f624214d9" alt="Keycloak dedicated client scope Mappers tab showing email, firstName, and lastName User Property mappers" width="1557" height="497" data-path="assets/images/keycloak-client-attribute-mappers.png" />
    </Frame>

    Each mapper form looks like this — confirm the **Property**, **Friendly Name**, **SAML Attribute Name**, and **SAML Attribute NameFormat** match the table above before saving.

    <Frame caption="A single User Property mapper configured for the email attribute">
      <img src="https://mintcdn.com/coderabbit/u1stYU3Evd4yPnml/assets/images/keycloak-client-mapper-config.png?fit=max&auto=format&n=u1stYU3Evd4yPnml&q=85&s=4078f62f4f15c7cf9f32281e4f17e2a1" alt="Keycloak User Property mapper configuration panel with Property set to email, SAML Attribute Name set to mail, and NameFormat set to Basic" width="1114" height="490" data-path="assets/images/keycloak-client-mapper-config.png" />
    </Frame>

    Save each mapper.
  </Step>

  <Step title="Grant access to your users">
    Make sure the users who should sign in to CodeRabbit exist in this realm, with:

    * An **email** that ends in the domain you registered with CodeRabbit
    * **First name** and **Last name** populated — those flow into CodeRabbit via the mappers above

    If your realm restricts client access via client-level roles or custom authentication flows, ensure the users you want to sign in have the appropriate access for this client. Users who cannot access the client in Keycloak cannot complete SSO login to CodeRabbit.
  </Step>

  <Step title="Send the metadata to CodeRabbit and validate access">
    Collect your IdP metadata URL:

    ```
    https://<keycloak-host>/realms/<realm-name>/protocol/saml/descriptor
    ```

    Open it in a browser to sanity-check. You should see an XML `EntityDescriptor` containing an `IDPSSODescriptor`, an `HTTP-POST` `SingleSignOnService` endpoint, and a `ds:X509Certificate` block.

    Send the following to your account team:

    * Your organization's email domain
    * The metadata URL above — or, if Keycloak is not reachable publicly, the downloaded XML file or the manual values described in [What CodeRabbit needs from you](#what-coderabbit-needs-from-you)

    After CodeRabbit confirms the configuration is enabled, test the sign-in flow with a user account whose email matches your configured domain. Assigned users are added to your CodeRabbit organization automatically on first SSO login.
  </Step>
</Steps>

## What's next

<CardGroup cols={1}>
  <Card title="Enterprise SSO overview" href="/management/sso" icon="key" horizontal>
    Return to the SSO overview to see the shared rollout flow and other supported providers.
  </Card>

  <Card title="Roles and permissions" href="/management/roles" icon="shield-check" horizontal>
    Pair SSO with the right access controls by reviewing how roles work in your CodeRabbit organization.
  </Card>

  <Card title="Support" href="/support" icon="message-circle" horizontal>
    Reach out if you need the CodeRabbit service provider values or help troubleshooting the Keycloak setup.
  </Card>
</CardGroup>
