Enable inserting custom URL using basic auth

This commit is contained in:
tirongi
2023-11-21 19:13:19 +01:00
parent e4f2b78e9a
commit 681890a600
2 changed files with 24 additions and 9 deletions
@@ -15,7 +15,7 @@ class ElasticSearchUserPassword implements INodeCredential {
'Refer to <a target="_blank" href="https://www.elastic.co/guide/en/kibana/current/tutorial-secure-access-to-kibana.html">official guide</a> on how to get User Password from ElasticSearch' 'Refer to <a target="_blank" href="https://www.elastic.co/guide/en/kibana/current/tutorial-secure-access-to-kibana.html">official guide</a> on how to get User Password from ElasticSearch'
this.inputs = [ this.inputs = [
{ {
label: 'Cloud ID', label: 'Cloud ID or custom server URL',
name: 'cloudId', name: 'cloudId',
type: 'string' type: 'string'
}, },
@@ -144,15 +144,30 @@ export abstract class ElasticSearchBase {
} else if (cloudId) { } else if (cloudId) {
let username = getCredentialParam('username', credentialData, nodeData) let username = getCredentialParam('username', credentialData, nodeData)
let password = getCredentialParam('password', credentialData, nodeData) let password = getCredentialParam('password', credentialData, nodeData)
elasticSearchClientOptions = { if (cloudId.startsWith('http')) {
cloud: { let username = getCredentialParam('username', credentialData, nodeData)
id: cloudId let password = getCredentialParam('password', credentialData, nodeData)
}, elasticSearchClientOptions = {
auth: { node: cloudId,
username: username, auth: {
password: password username: username,
password: password
},
tls: {
rejectUnauthorized: false
}
} }
} } else{
elasticSearchClientOptions = {
cloud: {
id: cloudId
},
auth: {
username: username,
password: password
}
}
}
} }
return elasticSearchClientOptions return elasticSearchClientOptions
} }