mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Legacy ES client: use config.httpAuth instead of config.hosts.auth (#91276)
* Use httpAuth instead of host.auth * NIT
This commit is contained in:
parent
8ed1c3ca3e
commit
f1f206b2c8
2 changed files with 6 additions and 9 deletions
|
@ -99,7 +99,6 @@ test('parses fully specified config', () => {
|
|||
"apiVersion": "v7.0.0",
|
||||
"hosts": Array [
|
||||
Object {
|
||||
"auth": "elastic:changeme",
|
||||
"headers": Object {
|
||||
"x-elastic-product-origin": "kibana",
|
||||
"xsrf": "something",
|
||||
|
@ -111,7 +110,6 @@ test('parses fully specified config', () => {
|
|||
"query": null,
|
||||
},
|
||||
Object {
|
||||
"auth": "elastic:changeme",
|
||||
"headers": Object {
|
||||
"x-elastic-product-origin": "kibana",
|
||||
"xsrf": "something",
|
||||
|
@ -123,7 +121,6 @@ test('parses fully specified config', () => {
|
|||
"query": null,
|
||||
},
|
||||
Object {
|
||||
"auth": "elastic:changeme",
|
||||
"headers": Object {
|
||||
"x-elastic-product-origin": "kibana",
|
||||
"xsrf": "something",
|
||||
|
@ -135,6 +132,7 @@ test('parses fully specified config', () => {
|
|||
"query": null,
|
||||
},
|
||||
],
|
||||
"httpAuth": "elastic:changeme",
|
||||
"keepAlive": true,
|
||||
"log": [Function],
|
||||
"pingTimeout": 12345,
|
||||
|
|
|
@ -106,11 +106,14 @@ export function parseElasticsearchClientConfig(
|
|||
esClientConfig.sniffInterval = getDurationAsMs(config.sniffInterval);
|
||||
}
|
||||
|
||||
const needsAuth = auth !== false && config.username && config.password;
|
||||
if (needsAuth) {
|
||||
esClientConfig.httpAuth = `${config.username}:${config.password}`;
|
||||
}
|
||||
|
||||
if (Array.isArray(config.hosts)) {
|
||||
const needsAuth = auth !== false && config.username && config.password;
|
||||
esClientConfig.hosts = config.hosts.map((nodeUrl: string) => {
|
||||
const uri = url.parse(nodeUrl);
|
||||
|
||||
const httpsURI = uri.protocol === 'https:';
|
||||
const httpURI = uri.protocol === 'http:';
|
||||
|
||||
|
@ -126,10 +129,6 @@ export function parseElasticsearchClientConfig(
|
|||
},
|
||||
};
|
||||
|
||||
if (needsAuth) {
|
||||
host.auth = `${config.username}:${config.password}`;
|
||||
}
|
||||
|
||||
return host;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue