mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Use the getBasicAuthHeader util function for Webhook
This commit is contained in:
parent
b10d103bd9
commit
1a62c77d46
2 changed files with 10 additions and 6 deletions
|
@ -348,13 +348,10 @@ describe('execute()', () => {
|
||||||
delete requestMock.mock.calls[0][0].configurationUtilities;
|
delete requestMock.mock.calls[0][0].configurationUtilities;
|
||||||
expect(requestMock.mock.calls[0][0]).toMatchInlineSnapshot(`
|
expect(requestMock.mock.calls[0][0]).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"auth": Object {
|
|
||||||
"password": "123",
|
|
||||||
"username": "abc",
|
|
||||||
},
|
|
||||||
"axios": undefined,
|
"axios": undefined,
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
"headers": Object {
|
"headers": Object {
|
||||||
|
"Authorization": "Basic YWJjOjEyMw==",
|
||||||
"aheader": "a value",
|
"aheader": "a value",
|
||||||
},
|
},
|
||||||
"logger": Object {
|
"logger": Object {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {
|
||||||
SecurityConnectorFeatureId,
|
SecurityConnectorFeatureId,
|
||||||
} from '@kbn/actions-plugin/common/types';
|
} from '@kbn/actions-plugin/common/types';
|
||||||
import { renderMustacheString } from '@kbn/actions-plugin/server/lib/mustache_renderer';
|
import { renderMustacheString } from '@kbn/actions-plugin/server/lib/mustache_renderer';
|
||||||
|
import { combineHeadersWithBasicAuthHeader } from '@kbn/actions-plugin/server/lib';
|
||||||
import { SSLCertType, WebhookAuthType } from '../../../common/webhook/constants';
|
import { SSLCertType, WebhookAuthType } from '../../../common/webhook/constants';
|
||||||
import { getRetryAfterIntervalFromHeaders } from '../lib/http_response_retry_header';
|
import { getRetryAfterIntervalFromHeaders } from '../lib/http_response_retry_header';
|
||||||
import { nullableType } from '../lib/nullable';
|
import { nullableType } from '../lib/nullable';
|
||||||
|
@ -210,6 +211,7 @@ export async function executor(
|
||||||
isString(secrets.password)
|
isString(secrets.password)
|
||||||
? { auth: { username: secrets.user, password: secrets.password } }
|
? { auth: { username: secrets.user, password: secrets.password } }
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
const sslCertificate =
|
const sslCertificate =
|
||||||
authType === WebhookAuthType.SSL &&
|
authType === WebhookAuthType.SSL &&
|
||||||
((isString(secrets.crt) && isString(secrets.key)) || isString(secrets.pfx))
|
((isString(secrets.crt) && isString(secrets.key)) || isString(secrets.pfx))
|
||||||
|
@ -233,14 +235,19 @@ export async function executor(
|
||||||
...(ca ? { ca: Buffer.from(ca, 'base64') } : {}),
|
...(ca ? { ca: Buffer.from(ca, 'base64') } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const headersWithBasicAuth = combineHeadersWithBasicAuthHeader({
|
||||||
|
username: basicAuth.auth?.username,
|
||||||
|
password: basicAuth.auth?.password,
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
|
||||||
const result: Result<AxiosResponse, AxiosError<{ message: string }>> = await promiseResult(
|
const result: Result<AxiosResponse, AxiosError<{ message: string }>> = await promiseResult(
|
||||||
request({
|
request({
|
||||||
axios: axiosInstance,
|
axios: axiosInstance,
|
||||||
method,
|
method,
|
||||||
url,
|
url,
|
||||||
logger,
|
logger,
|
||||||
...basicAuth,
|
headers: headersWithBasicAuth,
|
||||||
headers: headers ? headers : {},
|
|
||||||
data,
|
data,
|
||||||
configurationUtilities,
|
configurationUtilities,
|
||||||
sslOverrides,
|
sslOverrides,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue