mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
feat(Rundeck Node): Update credential with test and make useable in HTTP Request node (#3879)
* add support for authenticate, test to RundeckApi Credentials * ensure that the RunDeckApi note uses the authentication mechanism defined incredentials
This commit is contained in:
parent
b67e41b45e
commit
fc87650180
|
@ -1,4 +1,9 @@
|
|||
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
||||
import {
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class RundeckApi implements ICredentialType {
|
||||
name = 'rundeckApi';
|
||||
|
@ -19,4 +24,22 @@ export class RundeckApi implements ICredentialType {
|
|||
default: '',
|
||||
},
|
||||
];
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
headers: {
|
||||
'user-agent': 'n8n',
|
||||
'X-Rundeck-Auth-Token': '={{$credentials?.token}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '={{$credentials.url}}',
|
||||
url: '/api/14/system/info',
|
||||
method: 'GET',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@ export class RundeckApi {
|
|||
}
|
||||
|
||||
protected async request(method: string, endpoint: string, body: IDataObject, query: object) {
|
||||
const credentialType = 'rundeckApi';
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'user-agent': 'n8n',
|
||||
'X-Rundeck-Auth-Token': this.credentials?.token,
|
||||
},
|
||||
rejectUnauthorized: false,
|
||||
method,
|
||||
qs: query,
|
||||
|
@ -30,7 +28,11 @@ export class RundeckApi {
|
|||
};
|
||||
|
||||
try {
|
||||
return await this.executeFunctions.helpers.request!(options);
|
||||
return await this.executeFunctions.helpers.requestWithAuthentication.call(
|
||||
this.executeFunctions,
|
||||
credentialType,
|
||||
options,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.executeFunctions.getNode(), error);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue