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

# Connect OpenSearch with JSON Web Token – StackOne Hub

> Link a OpenSearch account in the StackOne Hub using JSON Web Token. End-user guide to authorize the integration and start using OpenSearch actions.

> [!WARNING]
>
> JWT authentication requires a cluster admin to enable the Security Plugin's `jwt_auth_domain` before this connector can use it. The cluster must also serve a TLS certificate signed by a Certificate Authority (public or internal) that the calling environment trusts.

## Enable JWT authentication on the OpenSearch cluster

A cluster administrator configures the OpenSearch Security plugin to accept JWTs by adding a `jwt_auth_domain` block to `config/opensearch-security/config.yml` and applying it with `securityadmin.sh`. This step is one-time — end users creating connections can skip it if the admin has already enabled JWT.

**1. Add the jwt\_auth\_domain block to config.yml**

Sample block using an HMAC shared secret. For RSA or ECDSA, set `signing_key` to the (non-Base64-encoded) public key wrapped in `-----BEGIN PUBLIC KEY-----` / `-----END PUBLIC KEY-----` — the plugin auto-detects the algorithm. For a rotating IdP, use `jwks_uri` in place of `signing_key`.

<ul>
  <li>
    ```yaml theme={null}
    jwt_auth_domain:
      http_enabled: true
      transport_enabled: true
      order: 0
      http_authenticator:
        type: jwt
        challenge: false
        config:
          signing_key: "<base64-encoded HMAC secret>"
          jwt_header: "Authorization"
          jwt_url_parameter: null
          subject_key: null
          roles_key: null
          required_audience: null
          required_issuer: null
          jwt_clock_skew_tolerance_seconds: 20
      authentication_backend:
        type: noop
    ```
  </li>

  <li>Apply the config with `plugins/opensearch-security/tools/securityadmin.sh` and reload.</li>
  <li>Because JWTs are self-contained, `authentication_backend` is set to `noop`.</li>
  <li>Full reference: [JSON Web Token authentication](https://docs.opensearch.org/latest/security/authentication-backends/jwt/).</li>
</ul>

**2. Configure the claim-to-role mapping**

Once JWT auth accepts the token, the user still needs mapped OpenSearch roles.

<ul>
  <li>The subject claim (`sub` by default) becomes the OpenSearch username. Override with `subject_key` if your IdP puts the username elsewhere.</li>
  <li>The `roles_key` config value points at the claim carrying the user's role list. Set it (e.g. `roles_key: "roles"`) if you want the JWT to carry OpenSearch role membership.</li>
  <li>Alternatively, map the subject or a backend role via Dashboards: **Security** > **Roles** > select role > **Mapped users** > **Manage mapping** > **Map**.</li>
</ul>

## Generate a signed JWT from your identity provider

Sign in to your IdP (Okta, Azure AD, Auth0, or a custom signing service) and mint a JWT for the integration user. The token must be signed with the same key material the cluster is configured to verify.

**1. Add the required claims to the token**

The cluster validates these claims automatically:

<ul>
  <li>Include a `sub` claim (or the `subject_key` claim your admin configured) whose value the cluster's role-mapping recognises.</li>
  <li>Include an `exp` (expiration) claim reasonable for the workload. Long-lived tokens are simpler; short-lived tokens are safer — the cluster tolerates up to `jwt_clock_skew_tolerance_seconds` (default 30 seconds) of clock drift.</li>
  <li>If `required_audience` or `required_issuer` are set on the cluster, the token must include matching `aud` / `iss` claims — otherwise the request is rejected as unauthorised.</li>
  <li>Supported algorithms: HS256/384/512 (HMAC), RS256/384/512 (RSA), PS256/384/512 (RSA-PSS), ES256/384/512 (ECDSA).</li>
  <li>Short-lived tokens must be refreshed externally before expiry — the connector does not refresh them automatically. When your token nears `exp`, generate a new one and update the connection.</li>
</ul>

## Copy the endpoint URL

Enter the fully-qualified HTTPS URL of your cluster's REST API.

**1. Copy the URL from your platform**

The URL depends on your deployment.

<ul>
  <li>For **self-hosted** clusters, an HTTPS URL to the cluster's REST port (default `9200`).</li>
  <li>For **hosted providers with JWT support**, the endpoint URL is shown in the provider's console.</li>
  <li>The URL must use HTTPS — the Security Plugin requires TLS.</li>
  <li>No trailing slash.</li>
</ul>

## Verify the credentials

Verify the token round-trips through the cluster before configuring the connector.

**1. Verify with a manual health check**

From a shell that can reach the cluster, send `GET /_cluster/health` with the `Authorization: Bearer <jwt>` header and inspect the response:

<ul>
  <li>**200 OK** with a JSON status — the token is accepted.</li>
  <li>**401 Unauthorized** — the JWT signature or claims don't validate. Check that the `signing_key` on the cluster matches the IdP's signing key, that `required_audience` / `required_issuer` (if set) match the token, and that `exp` has not passed.</li>
  <li>**403 Forbidden** — the JWT authenticates but the subject / roles claim is not mapped to a role with the required permissions. Update role mapping in Dashboards or the `roles_key` claim in the token.</li>
</ul>

## Enter credentials in StackOne Hub

Paste the values below into StackOne Hub to connect the account.

**1. Fill in the connection fields**

Copy each value from the JWT and the cluster endpoint.

<ul>
  <li>**OpenSearch Endpoint URL** — the HTTPS endpoint from step 3.</li>
  <li>**JSON Web Token** — paste the JWT exactly as issued (three base64url segments separated by dots). Do not add the `Bearer` prefix — StackOne adds it automatically.</li>
  <li>**OpenSearch Dashboards URL** — optional. Required only for `dashboards_*` actions. Leave blank for core datasync workflows.</li>
</ul>

## Link the Account

**1. Connect**

<ul>
  <li>Click **Connect**.</li>
  <li>If applicable, the provider will redirect you to a sign-in or authorization page. Complete the provider's authorization flow.</li>
  <li>Once authorization is successful, you will see a confirmation popup.</li>
</ul>

**2. Use Actions**

Connect an AI platform to the linked account's actions. See [AI Platforms](https://docs.stackone.com/ai-platforms/overview.md).

Other ways to call actions are listed in [Protocols & SDKs](https://docs.stackone.com/connect/protocols-and-sdks.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.