Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 28 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
17a39a3
datadog
bramkn Jun 21, 2024
b8b1a26
filescan
bramkn Jun 21, 2024
62defc5
Elastic
bramkn Jun 21, 2024
86503a8
Iris Dfir
bramkn Jun 21, 2024
ac846fc
remove delete body
bramkn Jun 24, 2024
7aa66ef
Malcore
bramkn Jun 24, 2024
e5fe067
Dynatrace
bramkn Jun 24, 2024
ab4ab8b
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Jul 3, 2024
911666e
Update Dynatrace
Joffcom Jul 3, 2024
96ab1f6
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Jul 3, 2024
d7f73d5
Update Filescan
Joffcom Jul 3, 2024
9d00698
Update Datadog
Joffcom Jul 3, 2024
3643a0d
Update Iris
Joffcom Jul 3, 2024
6e3ed07
Update Elastic
Joffcom Jul 3, 2024
a4e3914
Update Malcore
Joffcom Jul 3, 2024
24bbb74
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Jul 8, 2024
4c346c3
Rename IRIS DFIR to DFIR-IRIS to match website brand
Joffcom Jul 9, 2024
d2f5e40
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Jul 9, 2024
6b4ae52
Update elastic security credential to work with the node
Joffcom Jul 24, 2024
a925eda
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Jul 24, 2024
724663e
Fix credential
Joffcom Jul 24, 2024
93f9adf
fix credential properly
Joffcom Jul 24, 2024
b27cc44
Update packages/nodes-base/credentials/MalcoreApi.credentials.ts
Joffcom Aug 21, 2024
f607b16
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Aug 21, 2024
cc8a017
Merge Elastic Credentials
Joffcom Aug 21, 2024
e193127
Remove comments
Joffcom Aug 21, 2024
0c041a2
Merge branch 'master' of github.com:n8n-io/n8n into credentials-batch1
Joffcom Aug 23, 2024
706ffc0
Remove comment
Joffcom Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions packages/nodes-base/credentials/DatadogApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import type {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';

export class DatadogApi implements ICredentialType {
name = 'datadogApi';

displayName = 'Datadog API';

documentationUrl = 'datadog';

icon = { light: 'file:icons/Datadog.svg', dark: 'file:icons/Datadog.svg' } as const;

httpRequestNode = {
name: 'Datadog',
docsUrl: 'https://docs.datadoghq.com/api/latest/',
apiBaseUrlPlaceholder: 'https://api.datadoghq.com/api/v1/metrics',
};

properties: INodeProperties[] = [
{
displayName: 'URL',
name: 'url',
required: true,
type: 'string',
default: 'https://api.datadoghq.com',
},
{
displayName: 'API Key',
name: 'apiKey',
required: true,
type: 'string',
typeOptions: { password: true },
default: '',
},
{
displayName: 'APP Key',
name: 'appKey',
required: false,
type: 'string',
default: '',
typeOptions: { password: true },
description: 'For some endpoints, you also need an Application key.',
},
];

async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
requestOptions.headers = {
'DD-API-KEY': credentials.apiKey,
'DD-APPLICATION-KEY': credentials.appKey,
};
if (!requestOptions.headers['DD-APPLICATION-KEY']) {
delete requestOptions.headers['DD-APPLICATION-KEY'];
}

return requestOptions;
}

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.url}}',
url: '/api/v1/validate',
method: 'GET',
},
};
}
67 changes: 67 additions & 0 deletions packages/nodes-base/credentials/DfirIrisApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';

export class DfirIrisApi implements ICredentialType {
name = 'dfirIrisApi';

displayName = 'DFIR-IRIS API';

documentationUrl = 'dfiriris';

icon = { light: 'file:icons/DfirIris.svg', dark: 'file:icons/DfirIris.svg' } as const;

httpRequestNode = {
name: 'DFIR-IRIS',
docsUrl: 'https://docs.dfir-iris.org/operations/api/',
apiBaseUrlPlaceholder: 'http://<yourserver_ip>/manage/cases/list',
};

properties: INodeProperties[] = [
{
displayName: 'Base URL',
name: 'baseUrl',
type: 'string',
default: '',
placeholder: 'e.g. https://localhost',
description:
'The API endpoints are reachable on the same Address and port as the web interface.',
required: true,
},
{
displayName: 'API Key',
name: 'apiKey',
required: true,
type: 'string',
typeOptions: { password: true },
default: '',
},
{
displayName: 'Ignore SSL Issues',
name: 'skipSslCertificateValidation',
type: 'boolean',
default: false,
},
];

authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.apiKey}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.baseUrl}}',
url: '/api/ping',
method: 'GET',
skipSslCertificateValidation: '={{$credentials.skipSslCertificateValidation}}',
},
};
}
37 changes: 37 additions & 0 deletions packages/nodes-base/credentials/DynatraceApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';

export class DynatraceApi implements ICredentialType {
name = 'dynatraceApi';

displayName = 'DynatraceAPI';

documentationUrl = 'dynatrace';

icon = { light: 'file:icons/Dynatrace.svg', dark: 'file:icons/Dynatrace.svg' } as const;

httpRequestNode = {
name: 'Dynatrace',
docsUrl: 'https://docs.dynatrace.com/docs/dynatrace-api',
apiBaseUrlPlaceholder: 'https://{your-environment-id}.live.dynatrace.com/api/v2/events',
};

properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
required: true,
type: 'string',
typeOptions: { password: true },
default: '',
},
];

authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Api-Token {{$credentials.apiKey}}',
},
},
};
}
85 changes: 79 additions & 6 deletions packages/nodes-base/credentials/ElasticSecurityApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
import type {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';

export class ElasticSecurityApi implements ICredentialType {
name = 'elasticSecurityApi';
Expand All @@ -8,12 +14,42 @@ export class ElasticSecurityApi implements ICredentialType {
documentationUrl = 'elasticSecurity';

properties: INodeProperties[] = [
{
displayName: 'Base URL',
name: 'baseUrl',
type: 'string',
default: '',
placeholder: 'e.g. https://mydeployment.kb.us-central1.gcp.cloud.es.io:9243',
description: "Referred to as Kibana 'endpoint' in the Elastic deployment dashboard",
required: true,
},
{
displayName: 'Type',
name: 'type',
type: 'options',
options: [
{
name: 'API Key',
value: 'apiKey',
},
{
name: 'Basic Auth',
value: 'basicAuth',
},
],
default: 'basicAuth',
},
{
displayName: 'Username',
name: 'username',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
type: ['basicAuth'],
},
},
},
{
displayName: 'Password',
Expand All @@ -24,15 +60,52 @@ export class ElasticSecurityApi implements ICredentialType {
},
default: '',
required: true,
displayOptions: {
show: {
type: ['basicAuth'],
},
},
},
{
displayName: 'Base URL',
name: 'baseUrl',
displayName: 'API Key',
name: 'apiKey',
required: true,
type: 'string',
typeOptions: { password: true },
default: '',
placeholder: 'e.g. https://mydeployment.kb.us-central1.gcp.cloud.es.io:9243',
description: "Referred to as Kibana 'endpoint' in the Elastic deployment dashboard",
required: true,
displayOptions: {
show: {
type: ['apiKey'],
},
},
},
];

async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
if (credentials.type === 'apiKey') {
requestOptions.headers = {
Authorization: `ApiKey ${credentials.apiKey}`,
};
} else {
requestOptions.auth = {
username: credentials.username as string,
password: credentials.password as string,
};
requestOptions.headers = {
'kbn-xsrf': true,
};
}
return requestOptions;
}

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.baseUrl}}',
url: '/api/endpoint/metadata',
method: 'GET',
},
};
}
50 changes: 50 additions & 0 deletions packages/nodes-base/credentials/FilescanApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';

export class FilescanApi implements ICredentialType {
name = 'filescanApi';

displayName = 'Filescan API';

documentationUrl = 'filescan';

icon = { light: 'file:icons/Filescan.svg', dark: 'file:icons/Filescan.svg' } as const;

httpRequestNode = {
name: 'Filescan',
docsUrl: 'https://www.filescan.io/api/docs',
apiBaseUrlPlaceholder: 'https://www.filescan.io/api/system/do-healthcheck',
};

properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
required: true,
type: 'string',
typeOptions: { password: true },
default: '',
},
];

authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'X-Api-Key': '={{$credentials.apiKey}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://www.filescan.io/api',
url: '/system/do-healthcheck',
method: 'GET',
},
};
}
51 changes: 51 additions & 0 deletions packages/nodes-base/credentials/MalcoreApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';

export class MalcoreApi implements ICredentialType {
name = 'malcoreApi';

displayName = 'MalcoreAPI';

documentationUrl = 'malcore';

icon = { light: 'file:icons/Malcore.png', dark: 'file:icons/Malcore.png' } as const;

httpRequestNode = {
name: 'Malcore',
docsUrl: 'https://malcore.readme.io/reference/upload',
apiBaseUrlPlaceholder: 'https://api.malcore.io/api/urlcheck',
};

properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
required: true,
type: 'string',
typeOptions: { password: true },
default: '',
},
];

authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
apiKey: '={{$credentials.apiKey}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.malcore.io/api',
url: '/urlcheck',
method: 'POST',
body: { url: 'google.com' },
},
};
}
1 change: 1 addition & 0 deletions packages/nodes-base/credentials/icons/Datadog.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading