[Backport 6.x] ApiKey should take precedence over basic auth (#1116)

* ApiKey should take precedence over basic auth

* Updated docs

* Updated test

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2020-03-13 13:41:47 +01:00
committed by GitHub
parent 6839df018a
commit c386190c93
4 changed files with 103 additions and 7 deletions

View File

@ -33,6 +33,8 @@ const client = new Client({
You can provide your credentials by passing the `username` and `password` parameters via the `auth` option.
NOTE: If you provide both basic authentication credentials and the Api Key configuration, the Api Key will take precedence.
[source,js]
----
const { Client } = require('@elastic/elasticsearch')
@ -60,6 +62,8 @@ const client = new Client({
You can use the https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey] authentication by passing the `apiKey` parameter via the `auth` option. +
The `apiKey` parameter can be either a base64 encoded string or an object with the values that you can obtain from the https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[create api key endpoint].
NOTE: If you provide both basic authentication credentials and the Api Key configuration, the Api Key will take precedence.
[source,js]
----
const { Client } = require('@elastic/elasticsearch')