Skip to content

Support Elastic Cloud API keys in the api_key option#215

Open
arenard wants to merge 1 commit into
logstash-plugins:mainfrom
arenard:feature/cloud-api-key-support
Open

Support Elastic Cloud API keys in the api_key option#215
arenard wants to merge 1 commit into
logstash-plugins:mainfrom
arenard:feature/cloud-api-key-support

Conversation

@arenard

@arenard arenard commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Allows an Elastic Cloud API key (the essu_-prefixed keys, including the unified Serverless keys) to be used in the api_key option. These keys are not in the id:api_key form and cannot currently be used with this filter.

Background

The api_key value is turned into an Authorization: ApiKey <value> header. The existing logic base64-encodes any value that is not already valid standard base64. An essu_ key is neither an id:api_key pair nor valid standard base64 (the essu_ prefix contains _, which is outside the standard base64 alphabet), so it ends up being base64-encoded a second time and Elasticsearch rejects the resulting header.

Elasticsearch accepts these keys directly as Authorization: ApiKey <key> (Cloud API key authentication, available since Elasticsearch 9.1), so the gap is only on the Logstash side.

Change

setup_api_key now recognises the essu_ prefix and forwards such keys unchanged. Raw id:api_key pairs and their base64-encoded form keep their previous behaviour, so existing configurations are unaffected.

Tests

Added a unit test that asserts an essu_ key is sent verbatim, with no re-encoding. The existing raw and already-encoded api-key tests still pass.

Docs

Updated docs/index.asciidoc and the inline api_key option documentation to list the three accepted forms.

Related

The same fix is applied to the other two Elasticsearch plugins so the behaviour is consistent:

Elastic Cloud API keys (including the unified Serverless keys prefixed
with `essu_`) are opaque tokens that must be passed verbatim in the
`Authorization: ApiKey` header. The existing logic base64-encoded any
value that was not already valid standard base64, which double-encoded
`essu_` keys (the prefix contains `_`, outside the base64 alphabet) and
produced an Authorization header rejected by Elasticsearch.

Detect the `essu_` prefix and pass such keys through unchanged, while
keeping the existing handling for raw `id:api_key` pairs and their
base64-encoded form. Updates the `api_key` option documentation and adds
a unit test covering the cloud key case.
@arenard arenard force-pushed the feature/cloud-api-key-support branch from a481bf2 to 6d4daa6 Compare June 23, 2026 10:58
@mashhurs mashhurs linked an issue Jun 23, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Elastic Cloud org level API keys

1 participant