feat: Add new credentials for the HTTP Request node (#9833)

Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
Bram Kn
2024-08-23 19:19:05 +02:00
committed by GitHub
parent 6422fb33c0
commit 26f1af397b
16 changed files with 828 additions and 76 deletions

View File

@@ -21,21 +21,13 @@ export async function elasticSecurityApiRequest(
body: IDataObject = {},
qs: IDataObject = {},
) {
const {
username,
password,
baseUrl: rawBaseUrl,
} = (await this.getCredentials('elasticSecurityApi')) as ElasticSecurityApiCredentials;
const { baseUrl: rawBaseUrl } = (await this.getCredentials(
'elasticSecurityApi',
)) as ElasticSecurityApiCredentials;
const baseUrl = tolerateTrailingSlash(rawBaseUrl);
const token = Buffer.from(`${username}:${password}`).toString('base64');
const options: IRequestOptions = {
headers: {
Authorization: `Basic ${token}`,
'kbn-xsrf': true,
},
method,
body,
qs,
@@ -52,7 +44,7 @@ export async function elasticSecurityApiRequest(
}
try {
return await this.helpers.request(options);
return await this.helpers.requestWithAuthentication.call(this, 'elasticSecurityApi', options);
} catch (error) {
if (error?.error?.error === 'Not Acceptable' && error?.error?.message) {
error.error.error = `${error.error.error}: ${error.error.message}`;