Skip to content

Commit 421e7ea

Browse files
committed
API-Key: Use strict_encode64 to avoid adding new lines to result
1 parent 95ae715 commit 421e7ea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

elasticsearch-transport/lib/elasticsearch/transport/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def __auto_detect_adapter
244244
# Credentials is the base64 encoding of id and api_key joined by a colon
245245
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html
246246
def __encode(api_key)
247-
Base64.encode64([api_key[:id], api_key[:api_key]].join(':'))
247+
Base64.strict_encode64([api_key[:id], api_key[:api_key]].join(':'))
248248
end
249249
end
250250
end

elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
it 'Adds the ApiKey header to the connection' do
6464
expect(
6565
client.transport.connections.first.connection.headers['Authorization']
66-
).to eq("ApiKey #{Base64.encode64('my_id:my_api_key')}")
66+
).to eq("ApiKey #{Base64.strict_encode64('my_id:my_api_key')}")
6767
end
6868
end
6969

0 commit comments

Comments
 (0)