mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
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:
@@ -1,15 +1,11 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeCredentialTestResult,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
@@ -19,7 +15,6 @@ import {
|
||||
getVersion,
|
||||
handleListing,
|
||||
throwOnEmptyUpdate,
|
||||
tolerateTrailingSlash,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
@@ -33,12 +28,7 @@ import {
|
||||
connectorOperations,
|
||||
} from './descriptions';
|
||||
|
||||
import type {
|
||||
Connector,
|
||||
ConnectorCreatePayload,
|
||||
ConnectorType,
|
||||
ElasticSecurityApiCredentials,
|
||||
} from './types';
|
||||
import type { Connector, ConnectorCreatePayload, ConnectorType } from './types';
|
||||
|
||||
export class ElasticSecurity implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -58,7 +48,6 @@ export class ElasticSecurity implements INodeType {
|
||||
{
|
||||
name: 'elasticSecurityApi',
|
||||
required: true,
|
||||
testedBy: 'elasticSecurityApiTest',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
@@ -115,49 +104,6 @@ export class ElasticSecurity implements INodeType {
|
||||
return connectors.map(({ name, id }) => ({ name, value: id }));
|
||||
},
|
||||
},
|
||||
credentialTest: {
|
||||
async elasticSecurityApiTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const {
|
||||
username,
|
||||
password,
|
||||
baseUrl: rawBaseUrl,
|
||||
} = credential.data as ElasticSecurityApiCredentials;
|
||||
|
||||
const baseUrl = tolerateTrailingSlash(rawBaseUrl);
|
||||
|
||||
const token = Buffer.from(`${username}:${password}`).toString('base64');
|
||||
|
||||
const endpoint = '/cases/status';
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
Authorization: `Basic ${token}`,
|
||||
'kbn-xsrf': true,
|
||||
},
|
||||
method: 'GET',
|
||||
body: {},
|
||||
qs: {},
|
||||
uri: `${baseUrl}/api${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
await this.helpers.request(options);
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Authentication successful',
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
|
||||
Reference in New Issue
Block a user