You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _security/authentication-backends/jwt.md
+90-7Lines changed: 90 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -227,25 +227,108 @@ Validating the signature of the signed JWT is the last step in granting user acc
227
227
228
228
Rather than store the cryptographic key used for validation in the local `config.yml` file's `authc` section, you can specify a JSON Web Key Set (JWKS) endpoint to retrieve the key from its location on the issuer's server. This method of validating the JWT can help streamline management of public keys and certificates.
229
229
230
-
In OpenSearch, this method of validation makes use of the [OpenID Connect authentication domain configuration]({{site.url}}{{site.baseurl}}/security/authentication-backends/openid-connect/#configure-openid-connect-integration). To specify the JWKS endpoint, replace the `openid_connect_url` setting in the configuration with the `jwks_uri` setting and add the URL to the setting as its value. This is shown in the following example:
230
+
Starting with OpenSearch 3.3, JWT authentication now supports JWKS endpoints directly.
231
+
232
+
### Direct JWKS support with JWT authentication
233
+
234
+
You can now configure JWKS endpoints directly in the JWT authentication domain. This approach provides enhanced security through automated key rotation and dynamic key management.
231
235
232
236
```yml
233
-
openid_auth_domain:
237
+
jwt_auth_domain:
238
+
description: "Authenticate via JSON Web Token"
234
239
http_enabled: true
235
240
transport_enabled: true
236
241
order: 0
237
242
http_authenticator:
238
-
type: openid # use the OpenID Connect domain, since JWT is part of this authentication.
signing_key: null # Not used when jwks_uri is specified
248
+
jwt_header: "Authorization"
249
+
jwt_url_parameter: null
250
+
jwt_clock_skew_tolerance_seconds: 30
251
+
roles_key: "roles"
252
+
subject_key: "sub"
244
253
authentication_backend:
245
254
type: noop
246
255
```
247
256
248
-
The endpoint should be documented by the JWT issuer. You can use it to retrieve the keys needed to validate the signed JWT. For more information about the content and format of JSON Web Keys, see [JSON Web Key (JWK) format](https://datatracker.ietf.org/doc/html/rfc7517#section-4).
257
+
### JWKS configuration parameters
258
+
259
+
The following table describes the JWKS-specific configuration parameters:
260
+
261
+
Name | Description | Default
262
+
:--- | :--- | :---
263
+
`jwks_uri`| The JWKS endpoint URL. When specified, `signing_key` is ignored and keys are retrieved from this endpoint. | `null`
264
+
265
+
### (Advanced) Security protection
266
+
267
+
To help protect against denial-of-service (DoS) attacks and ensure secure JWKS operations, the Security plugin provides several protective measures including request limits, timeouts, and response size restrictions.
268
+
269
+
Name | Description | Default
270
+
:--- | :--- | :---
271
+
`max_jwks_keys`| Maximum number of keys to process from the JWKS response. Set to `-1` for no limits. | `-1`
272
+
`jwks_request_timeout_ms`| Maximum time in milliseconds allowed for a single HTTP request to the JWKS endpoint. | `5000`
273
+
`jwks_queued_thread_timeout_ms`| Maximum time in milliseconds a request can wait in the queue before processing. | `2500`
274
+
`max_jwks_response_size_bytes`| Maximum size in bytes for JWKS endpoint responses. | `1048576` (1MB)
275
+
`refresh_rate_limit_count`| Maximum number of JWKS refresh requests allowed within the time window. | `10`
276
+
`refresh_rate_limit_time_window_ms`| Time window in milliseconds for rate limiting JWKS refresh requests. | `10000` (10 seconds)
277
+
278
+
### JWT header with Key ID
279
+
280
+
When using JWKS, your JWT header must include a Key ID (`kid`) that identifies which specific key to use for verification:
The `kid` parameter is required when using JWKS endpoints and must match a key identifier in the JWKS response.
291
+
292
+
### Sample JWKS response
293
+
294
+
The JWKS endpoint should return a JSON object containing an array of public keys. Each key must include metadata such as the key type (`kty`), usage (`use`), key ID (`kid`), and algorithm (`alg`):
JWKS responses are cached to optimize performance:
314
+
315
+
- **Initial cache**: When JWKS is enabled, the system caches the JWKS endpoint response
316
+
- **Cache refresh triggers**:
317
+
- When a JWT contains a `kid` not found in the cache
318
+
- When cache entries expire based on HTTP cache headers
319
+
- During background refresh cycles
320
+
- **Rate limiting**: Prevents excessive requests to the JWKS endpoint (10 requests per 10-second window by default)
321
+
322
+
### Backward compatibility
323
+
324
+
The JWKS feature maintains full backward compatibility:
325
+
326
+
- When `jwks_uri` is not specified or set to `null`, the system uses the existing static `signing_key` mechanism
327
+
- Existing JWT configurations continue to work without modification
328
+
- You can switch between static keys and JWKS by updating the configuration
329
+
- When both `jwks_uri` and `signing_key` are configured, `jwks_uri` takes precedence and `signing_key` is ignored
330
+
331
+
For more information about the content and format of JSON Web Keys, see [JSON Web Key (JWK) format](https://datatracker.ietf.org/doc/html/rfc7517#section-4).
0 commit comments