Skip to content

Commit c7251bc

Browse files
committed
add doc for api key auth
1 parent 5673bbe commit c7251bc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/security.asciidoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ $client = ClientBuilder::create()
2424
Credentials are provided per-host, which allows each host to have their own set of credentials. All requests sent to the
2525
cluster will use the appropriate credentials depending on the node being talked to.
2626

27+
=== ApiKey Authentication
28+
29+
If your Elasticsearch cluster is secured by API keys as described https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[here], you have two options to provide the values to the client.
30+
Either use the `id` and `api_key` pair from the create API key API response or use the encoded token as described https://www.elastic.co/guide/en/elasticsearch/reference/7.1/security-api-create-api-key.html#_examples_83[here] in the last code snippet.
31+
32+
[source,php]
33+
----
34+
$client = ClientBuilder::create()
35+
->setApiKeyPairAuthentication('id', 'api_key') <1>
36+
->build();
37+
----
38+
<1> ApiKey pair of `id` and `api_key` from the create API key response.
39+
40+
[source,php]
41+
----
42+
$client = ClientBuilder::create()
43+
->setApiKeyAuthentication('encoded-api-key') <1>
44+
->build();
45+
----
46+
<1> Encoded ApiKey pair
47+
2748
=== SSL Encryption
2849

2950
Configuring SSL is a little more complex. You need to identify if your certificate has been signed by a public

0 commit comments

Comments
 (0)