Skip to main content

Enable JSON Web Token authentication on Aiven for OpenSearch®

Configure JSON Web Token (JWT) authentication to enable secure, stateless authentication for Aiven for OpenSearch®.

How it works

JWT authentication allows you to access Aiven for OpenSearch using tokens issued by your existing identity provider, eliminating the need to manage separate OpenSearch credentials or store session state on the server.

When you make a request to your Aiven for OpenSearch service:

  1. Token is validated: Aiven for OpenSearch validates the JWT token using the signing key you configure.
  2. User is identified: Aiven for OpenSearch extracts the username from the token's subject claim.
  3. Role is assigned: If configured, user roles are extracted from the token or managed separately in Aiven for OpenSearch.
  4. Access is granted: Valid tokens provide seamless access to your Aiven for OpenSearch service.

JWT authentication in Aiven for OpenSearch uses the known-signing-keys validation method, where Aiven for OpenSearch uses a trusted public key to verify a digital signature from your identity provider, ensuring that data is coming from a known and authentic source. JWT authentication in Aiven for OpenSearch is configured through Aiven's user configuration API rather than directly through the OpenSearch Security API.

Supported user_config options are as follows:

OptionData typeMore information
jwt.enabledBooleanEnables or disables JWT authentication. Set to true to activate JWT authentication.
jwt.signing_keyStringBase64-encoded signing key used to verify JWT tokens. Can be PEM-formatted RSA/ECDSA public key or HMAC secret key.
jwt.jwt_headerStringHTTP header name containing the JWT token. Default is Authorization.
jwt.jwt_url_parameterStringURL parameter name for passing JWT token as a query parameter. Optional alternative to header-based authentication.
jwt.subject_keyStringJWT claim key that contains the username/subject. Default is sub.
jwt.roles_keyStringJWT claim key that contains user roles. If not specified, roles must be managed separately in OpenSearch.
jwt.required_audienceStringRequired audience (aud) claim value that must be present in JWT tokens. Optional but recommended for security.
jwt.required_issuerStringRequired issuer (iss) claim value that must be present in JWT tokens. Optional but recommended for security.
jwt.jwt_clock_skew_tolerance_secondsIntegerClock skew tolerance in seconds for JWT token validation. Accounts for time differences between systems. Default is typically 30 seconds.

Prerequisites

  • Aiven for OpenSearch® version 2.4 or later
  • OpenSearch Dashboards version 2.19 or later
  • OpenSearch Security management enabled on your service
  • Base64-encoded signing key (PEM-formatted RSA/ECDSA public key or HMAC secret key)
  • Tool for enabling and configuring the JWT authentication:

Enable JWT authentication

  1. In the Aiven Console, access your Aiven for OpenSearch service where to enable the JWT authentication.
  2. Click Users in the sidebar.
  3. In the SSO authentication section, click Add method > JWT.
  4. In the Configure JWT authentication window, set up the following:
    • Signing algorithm: Choose RSA/ECDSA or HMAC.
    • Signing key: Enter your public key to verify your JWT signature when using RSA/ECDSA.
    • HTTP header name: Provide it if your JWT is transmitted as an HTTP header.
    • URL parameter name: Provide it if your JWT is transmitted as a URL parameter.
    • JWT claim key for subject: Enter the JWT payload key that contains the user's subject identifier to override the sub default.
    • JWT claim key for roles: Enter the JWT payload key that contains the user's roles to have them extracted from the JWT for authorization.
    • Required JWT audience: Provide a value for the aud claim in the JWT to restrict its audience.
    • Required JWT issuer: Provide a value for the iss claim in the JWT to restrict its issuer.
    • JWT Clock Skew Tolerance (seconds): Specify the maximum time difference between the JWT's issuer's clock and the OpenSearch server's clock.
  5. Click Enable to complete the setup and activate the configuration.

Related pages

Upstream OpenSearch JWT authentication documentation