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

# JWT authentication setup

> How to configure per-service JWT (JWKS) authentication providers for a ClickHouse Cloud service from the console

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <span>Beta</span>
            </a>;
  }
  return <a href="https://clickhouse.com/docs/reference/settings/beta-and-experimental-features#beta-features" className="betaBadge">
            <span>Beta feature</span>
        </a>;
};

export const VersionBadge = ({minVersion}) => <div className="versionBadge">
    <div className="versionIcon" style={{
  marginRight: "8px",
  marginTop: "4px"
}}>
      <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M5 14C5.82843 14 6.5 13.3284 6.5 12.5C6.5 11.6716 5.82843 11 5 11C4.17157 11 3.5 11.6716 3.5 12.5C3.5 13.3284 4.17157 14 5 14Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.25" />
        <path d="M5 5C5.82843 5 6.5 4.32843 6.5 3.5C6.5 2.67157 5.82843 2 5 2C4.17157 2 3.5 2.67157 3.5 3.5C3.5 4.32843 4.17157 5 5 5Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.25" />
        <path d="M13 10.5C13.8284 10.5 14.5 9.82843 14.5 9C14.5 8.17157 13.8284 7.5 13 7.5C12.1716 7.5 11.5 8.17157 11.5 9C11.5 9.82843 12.1716 10.5 13 10.5Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.25" />
        <path d="M11.5 9H9.5C9.03426 9 8.57493 8.89157 8.15836 8.68328C7.74179 8.475 7.37944 8.17259 7.1 7.8L5 5V11" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.25" />
      </svg>
    </div>
    Available in version {minVersion} and later
  </div>;

export const EnterprisePlanFeatureBadge = ({feature = 'This feature', support = false, linking_verb_are = false}) => {
  return <div className="enterprisePlanFeatureContainer">
            <div className="enterprisePlanFeatureBadge">
                Enterprise plan feature
            </div>
            <div>
                <p>{feature} {linking_verb_are ? 'are' : 'is'} available in the Enterprise plan. {support ? `Contact support to enable this feature.` : 'To upgrade, visit the plans page in the cloud console.'}</p>
            </div>
        </div>;
};

export const Image = ({img, alt, size = "lg", background}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  const backgroundColor = background === "white" ? "white" : background === "black" ? "rgb(31 31 28)" : undefined;
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} style={{
    backgroundColor
  }} />
      </Frame>
    </div>;
};

<BetaBadge />

<VersionBadge minVersion="26.4" />

<EnterprisePlanFeatureBadge feature="JWT authentication with a custom identity provider" support="true" />

<Tip>
  This guide covers configuring JWKS providers in the Cloud console. To learn how to generate a JWT and what its structure looks like — its required claims, the roles and grants claims, and how ephemeral users work — see the [JWT Authentication](/docs/operations/external-authenticators/jwt) reference.
</Tip>

ClickHouse Cloud lets you authenticate connections to a service with JSON Web Tokens (JWTs) validated against your own JSON Web Key Set (JWKS) endpoints. Instead of managing database credentials, your identity provider issues short-lived tokens that ClickHouse verifies against the public keys published at a JWKS URL you configure.

Once the feature is enabled for your organization, you configure these JWKS providers yourself, per service, from **Settings → Security** in the ClickHouse Cloud console.

<Note>
  To enable JWT providers for your organization, reach out to [support](https://clickhouse.com/support/program).
</Note>

<h2 id="before-you-begin">
  Before you begin
</h2>

To configure JWT providers for a service, you need:

* An organization on the **Enterprise** plan.
* A service running **ClickHouse version 26.4 or later**.
* A role with the `control-plane:service:manage` permission on the service (for example, **Admin** or **Service admin**). Members without it see the section as read only.
* A publicly reachable **HTTPS** JWKS URL that publishes at least one **RSA** key (tokens must be signed with **RS256**).

<Note>
  JWKS-based providers accept **RSA keys only**. Tokens signed with HMAC (`HS256`) or EC (`ES256`) keys cannot be verified against a JWKS endpoint and are rejected. A JWKS document may contain other key types, but at least one usable RSA key must be present.
</Note>

<h2 id="how-it-works">
  How it works
</h2>

The client (your identity provider or application) generates a JWT and signs it with its **private key**. The token must follow the expected [token format](/docs/operations/external-authenticators/jwt#token-claims). ClickHouse then verifies it against the **public** keys published at your JWKS URL:

1. ClickHouse reads the token's `kid` (key ID) header and selects the matching key from your JWKS document.
2. It verifies the token signature against that RSA public key and checks the `iss` (issuer) and `aud` (audience) claims against your provider configuration.
3. On success, the connection runs as an ephemeral user whose access rights come from the token's `clickhouse:grants` and `clickhouse:roles` claims, capped by the permission limit (the `default` user). See [Access rights](/docs/operations/external-authenticators/jwt#access-rights) for details.

ClickHouse validates and fetches the JWKS URL when you add or update a provider, so a misconfigured or unreachable URL is rejected up front.

<h2 id="add-a-jwt-provider">
  Add a JWT provider
</h2>

<Steps>
  <Step title="Open the service security settings" id="open-security-settings">
    Navigate to your service, open **Settings**, and scroll to the **Security** section. Find the **JWT authentication** card.

    <Image img="https://mintcdn.com/private-7c7dfe99/-6hzQ2QWO_HW75mL/images/cloud/security/jwt/jwt-section.png?fit=max&auto=format&n=-6hzQ2QWO_HW75mL&q=85&s=79179b401f3a527316bffe67be424977" size="lg" alt="JWT authentication section in service security settings" force width="1850" height="422" data-path="images/cloud/security/jwt/jwt-section.png" />
  </Step>

  <Step title="Open the providers flyout" id="open-flyout">
    Select **Set up JWT providers** (or **Manage JWT providers** if you already have some). The flyout opens with a new provider form ready to fill in.
  </Step>

  <Step title="Fill in the provider details" id="fill-provider-details">
    Complete the provider form and select **Save**.

    | Field                      | Description                                                                                                                                                              |
    | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | **Name**                   | A unique name for this provider on the service. Cannot be changed after creation.                                                                                        |
    | **Issuer**                 | The expected `iss` claim of incoming tokens.                                                                                                                             |
    | **Audience**               | The expected `aud` claim of incoming tokens.                                                                                                                             |
    | **JWKS URL**               | The public HTTPS URL that publishes your RSA public keys used to verify token signatures.                                                                                |
    | **Roles claim** (optional) | The token claim to read ClickHouse roles from. Leave blank to use the default claim name `clickhouse:roles`. Roles named in the token must already exist on the service. |
  </Step>

  <Step title="Add more providers if needed" id="add-more-providers">
    Use **Add another provider** to configure additional providers. A service can have at most five JWT providers.
  </Step>
</Steps>

<Warning>
  Deleting a JWT provider immediately stops accepting tokens issued for it, and any workloads still authenticating with those tokens will stop working.
</Warning>

<h2 id="limits">
  Limits
</h2>

* A maximum of **five** JWT providers per service.
* JWKS providers accept **RSA / RS256** keys only.
* The JWKS URL must be a public HTTPS endpoint. Private, internal, or link-local addresses are rejected.

<h2 id="related">
  Related
</h2>

* [JWT Authentication](/docs/operations/external-authenticators/jwt) — token claims, ephemeral users, and client usage.
