logstash-output-elasticsearch 11.22.16-java → 11.22.17-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 879ff0b99e2d13691ade229384790bc4372e083396cbb777587b2463d8fa05c1
4
- data.tar.gz: c2cc01a0602371c908857832bbf712d2297d0383ffb45e893af2c44e97cd4121
3
+ metadata.gz: d4bb66bdcf7a4f0d3557d0999e3c3737a1a75d8cb7fa26830339cf6e0e28b82d
4
+ data.tar.gz: 12bfde3746577a042a3ec3962f39b76e530a65a7cf34e856146e8b3fc2933495
5
5
  SHA512:
6
- metadata.gz: b3411e69c6aa2798b92cde0d242b8952a79b438c9e4875a40aaf39017c5120978c24378fff986f0d65f6a2b7dad7be6c69b65760b096bae443307448e7be6a59
7
- data.tar.gz: cbbbcb50f322e298a05e1d381344555137431cb45e34de65e26d2318c3db28ecb3945921fec036f2fb30ffedd6313ce5b9256160a9d8a4025f69243cfddd80ab
6
+ metadata.gz: 95d48b93014a46d8412add41d4e753ee1c0ef091f86ad2138825802bbaf416c5865abd7d8afa7df825361f2db010d0f5b189df4274991d02f4f67325ddab56fc
7
+ data.tar.gz: 607b5b63bc6a41067bd0d4a9c2f627dbb9ea007b43f6d69f8ec53e2d1e8177b9b37be0b76249e0cc310d0da541c981ac753db9cb1cece249404a7c33b8c92618
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 11.22.17
2
+ - Support base64-encoded and Elastic Cloud (`essu_`-prefixed) API keys in the `api_key` option; reject unrecognized formats at startup. [#1278](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1278)
3
+
1
4
  ## 11.22.16
2
5
  - Fix serverless compatibility: guard against nil params in pool requests and strip unsupported template settings (number_of_shards, number_of_replicas) on serverless
3
6
 
data/docs/index.asciidoc CHANGED
@@ -458,8 +458,12 @@ For more details on actions, check out the {ref}/docs-bulk.html[Elasticsearch bu
458
458
  Authenticate using Elasticsearch API key.
459
459
  Note that this option also requires SSL/TLS, which can be enabled by supplying a <<plugins-{type}s-{plugin}-cloud_id>>, a list of HTTPS <<plugins-{type}s-{plugin}-hosts>>, or by setting <<plugins-{type}s-{plugin}-ssl,`ssl_enabled => true`>>.
460
460
 
461
- Format is `id:api_key` where `id` and `api_key` are as returned by the
462
- Elasticsearch {ref}/security-api-create-api-key.html[Create API key API].
461
+ The format is `id:api_key`, where `id` and `api_key` are as returned by the
462
+ Elasticsearch
463
+ {ref}/security-api-create-api-key.html[Create
464
+ API key API]. The base64-encoded form of that pair is also accepted, as is an
465
+ https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys[Elastic Cloud API key]
466
+ (prefixed with `essu_`), which is used as-is.
463
467
 
464
468
  [id="plugins-{type}s-{plugin}-bulk_path"]
465
469
  ===== `bulk_path`
@@ -188,9 +188,38 @@ module LogStash; module Outputs; class ElasticSearch;
188
188
  def self.setup_api_key(logger, params)
189
189
  api_key = params["api_key"]
190
190
 
191
- return {} unless (api_key && api_key.value)
191
+ return {} unless (api_key&.value)
192
192
 
193
- { "Authorization" => "ApiKey " + Base64.strict_encode64(api_key.value) }
193
+ token = resolve_api_key(api_key.value)
194
+ { "Authorization" => "ApiKey #{token}" }
195
+ end
196
+
197
+ # Resolves the `api_key` value into the credential used in the
198
+ # `Authorization: ApiKey` header. An already base64-encoded key and an Elastic
199
+ # Cloud API key are used as-is; a raw `id:api_key` pair is base64-encoded. An
200
+ # unrecognized value is rejected so a malformed key surfaces at startup rather
201
+ # than as a later authentication failure.
202
+ def self.resolve_api_key(key_value)
203
+ if base64?(key_value) || cloud_api_key?(key_value)
204
+ key_value
205
+ elsif key_value.match?(/\A[^:]+:[^:]+\z/)
206
+ Base64.strict_encode64(key_value)
207
+ else
208
+ raise LogStash::ConfigurationError, "Invalid api_key format. Expected a base64-encoded key, an 'id:api_key' pair, or a Cloud API key (essu_ prefix)."
209
+ end
210
+ end
211
+
212
+ # Elastic Cloud API keys (such as the unified Serverless keys) are opaque
213
+ # tokens prefixed with `essu_` that Elasticsearch accepts verbatim in the
214
+ # `Authorization: ApiKey` header, with no base64 encoding.
215
+ def self.cloud_api_key?(string)
216
+ string.match?(/\Aessu_.+/)
217
+ end
218
+
219
+ def self.base64?(string)
220
+ string == Base64.strict_encode64(Base64.strict_decode64(string))
221
+ rescue ArgumentError
222
+ false
194
223
  end
195
224
 
196
225
  private
@@ -16,7 +16,8 @@ module LogStash; module PluginMixins; module ElasticSearch
16
16
  :password => { :validate => :password },
17
17
 
18
18
  # Authenticate using Elasticsearch API key.
19
- # format is id:api_key (as returned by https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Create API key])
19
+ # Format is either the `id:api_key` pair (as returned by https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[Create API key]),
20
+ # its base64-encoded form, or an https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys[Elastic Cloud API key] (prefixed with `essu_`) can be used.
20
21
  :api_key => { :validate => :password },
21
22
 
22
23
  # Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
@@ -1618,6 +1618,32 @@ describe LogStash::Outputs::ElasticSearch do
1618
1618
  end; end
1619
1619
  end
1620
1620
 
1621
+ context "with an already base64-encoded API key" do
1622
+ let(:api_key) { Base64.strict_encode64("some_id:some_api_key") }
1623
+ let(:options) { { "ssl_enabled" => true, "api_key" => ::LogStash::Util::Password.new(api_key) } }
1624
+ let(:base64_api_key) { "ApiKey #{api_key}" }
1625
+
1626
+ it_behaves_like 'secure api-key authenticated client'
1627
+ end
1628
+
1629
+ context "with an Elastic Cloud API key (essu_ prefix)" do
1630
+ let(:api_key) { "essu_VFZGblZreFhTekJ4ZDB4M2NHUnZRMEU2YzNWd1pYSnpaV055WlhRPQ==AAAAAAAA" }
1631
+ let(:options) { { "ssl_enabled" => true, "api_key" => ::LogStash::Util::Password.new(api_key) } }
1632
+
1633
+ it "sets the Authorization header verbatim without re-encoding" do
1634
+ expect(manticore_options[:headers]).to eq({ "Authorization" => "ApiKey #{api_key}" })
1635
+ end
1636
+ end
1637
+
1638
+ context "with an unrecognized api_key format" do
1639
+ let(:do_register) { false }
1640
+ let(:options) { { "ssl_enabled" => true, "api_key" => ::LogStash::Util::Password.new("not-a-valid-key") } }
1641
+
1642
+ it "fails registration with a configuration error" do
1643
+ expect { subject.register }.to raise_error(LogStash::ConfigurationError, /Invalid api_key format/)
1644
+ end
1645
+ end
1646
+
1621
1647
  context "when set without ssl_enabled => true" do
1622
1648
  let(:do_register) { false } # this is what we want to test, so we disable the before(:each) call
1623
1649
  let(:options) { { "api_key" => api_key } }
data/version CHANGED
@@ -1 +1 @@
1
- 11.22.16
1
+ 11.22.17
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.22.16
4
+ version: 11.22.17
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-07-06 00:00:00.000000000 Z
10
+ date: 2026-07-17 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: manticore