mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
feat(MISP Node): Update credential to support HTTP Request node (#7268)
This commit is contained in:
parent
6d7fe95c58
commit
e4c302c683
|
@ -1,4 +1,9 @@
|
||||||
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import type {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class MispApi implements ICredentialType {
|
export class MispApi implements ICredentialType {
|
||||||
name = 'mispApi';
|
name = 'mispApi';
|
||||||
|
@ -29,4 +34,21 @@ export class MispApi implements ICredentialType {
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '={{$credentials.apiKey}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: '={{$credentials.baseUrl.replace(new RegExp("/$"), "")}}',
|
||||||
|
url: '/tags',
|
||||||
|
skipSslCertificateValidation: '={{$credentials.allowUnauthorizedCerts}}',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,11 @@ export async function mispApiRequest(
|
||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { baseUrl, apiKey, allowUnauthorizedCerts } = (await this.getCredentials(
|
const { baseUrl, allowUnauthorizedCerts } = (await this.getCredentials(
|
||||||
'mispApi',
|
'mispApi',
|
||||||
)) as MispCredentials;
|
)) as MispCredentials;
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
|
||||||
Authorization: apiKey,
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
qs,
|
qs,
|
||||||
|
@ -44,7 +41,7 @@ export async function mispApiRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'mispApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// MISP API wrongly returns 403 for malformed requests
|
// MISP API wrongly returns 403 for malformed requests
|
||||||
if (error.statusCode === 403) {
|
if (error.statusCode === 403) {
|
||||||
|
|
Loading…
Reference in a new issue