mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core) Simplify authentication type (#3578)
* ⚡ Add generic auth type * ⚡ Remove queryAuth * ⚡ Remove bearer * ⚡ Remove headerAuth * ⚡ Remove basicAuth * ⚡ Adjust tests * ⚡ Small improvements * 👕 Fix lint issue
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBearer,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
@@ -17,9 +17,13 @@ export class AsanaApi implements ICredentialType {
|
||||
},
|
||||
];
|
||||
|
||||
authenticate = {
|
||||
type: 'bearer',
|
||||
properties: {},
|
||||
} as IAuthenticateBearer;
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateQueryAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -24,13 +24,14 @@ export class CalApi implements ICredentialType {
|
||||
},
|
||||
];
|
||||
|
||||
authenticate = {
|
||||
type: 'queryAuth',
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
key: 'apiKey',
|
||||
value: '={{$credentials.apiKey}}',
|
||||
qs: {
|
||||
apiKey: '={{$credentials.apiKey}}',
|
||||
},
|
||||
},
|
||||
} as IAuthenticateQueryAuth;
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateHeaderAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -30,13 +30,16 @@ export class GithubApi implements ICredentialType {
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
authenticate: IAuthenticateHeaderAuth = {
|
||||
type: 'headerAuth',
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
name: 'Authorization',
|
||||
value: '=token {{$credentials?.accessToken}}',
|
||||
headers: {
|
||||
Authorization: '=token {{$credentials?.accessToken}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '={{$credentials?.server}}',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateHeaderAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
@@ -26,11 +26,13 @@ export class HttpHeaderAuth implements ICredentialType {
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
authenticate = {
|
||||
type: 'headerAuth',
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
name: '={{credentials.name}}',
|
||||
value: '={{credentials.value}}',
|
||||
headers: {
|
||||
'={{$credentials.name}}': '={{$credentials.value}}',
|
||||
},
|
||||
},
|
||||
} as IAuthenticateHeaderAuth;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBearer,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -30,8 +30,12 @@ export class Magento2Api implements ICredentialType {
|
||||
},
|
||||
};
|
||||
|
||||
authenticate = {
|
||||
type: 'bearer',
|
||||
properties: {},
|
||||
} as IAuthenticateBearer;
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBasicAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -30,13 +30,17 @@ export class MailjetEmailApi implements ICredentialType {
|
||||
description: 'Whether to allow to run the API call in a Sandbox mode, where all validations of the payload will be done without delivering the message',
|
||||
},
|
||||
];
|
||||
authenticate: IAuthenticateBasicAuth = {
|
||||
type: 'basicAuth',
|
||||
properties: {
|
||||
userPropertyName: 'apiKey',
|
||||
passwordPropertyName: 'secretKey',
|
||||
},
|
||||
};
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
auth: {
|
||||
username: '={{$credentials.apiKey}}',
|
||||
password: '={{$credentials.secretKey}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: `https://api.mailjet.com`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateHeaderAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -17,13 +17,16 @@ export class MailjetSmsApi implements ICredentialType {
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
authenticate: IAuthenticateHeaderAuth = {
|
||||
type: 'headerAuth',
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
name: 'Authorization',
|
||||
value: '=Bearer {{$credentials.token}}',
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.token}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: `https://api.mailjet.com`,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
IAuthenticateQueryAuth,
|
||||
ICredentialTestRequest,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
@@ -19,11 +18,12 @@ export class PipedriveApi implements ICredentialType {
|
||||
},
|
||||
];
|
||||
|
||||
authenticate = {
|
||||
type: 'queryAuth',
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
key: 'api_token',
|
||||
value: '={{$credentials.apiToken}}',
|
||||
qs: {
|
||||
api_token: '={{$credentials.apiToken}}',
|
||||
},
|
||||
},
|
||||
} as IAuthenticateQueryAuth;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBasicAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -40,10 +40,17 @@ export class ServiceNowBasicApi implements ICredentialType {
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
authenticate: IAuthenticateBasicAuth = {
|
||||
type: 'basicAuth',
|
||||
properties: {},
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
auth: {
|
||||
username: '={{$credentials.user}}',
|
||||
password: '={{$credentials.password}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '=https://{{$credentials?.subdomain}}.service-now.com',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBearer,
|
||||
IAuthenticateQueryAuth,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -19,12 +18,16 @@ export class SlackApi implements ICredentialType {
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
authenticate: IAuthenticateBearer = {
|
||||
type: 'bearer',
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
tokenPropertyName: 'accessToken',
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: 'https://slack.com',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBearer,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -18,12 +18,14 @@ export class TodoistApi implements ICredentialType {
|
||||
|
||||
];
|
||||
|
||||
authenticate = {
|
||||
type: 'bearer',
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
tokenPropertyName: 'apiKey',
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.apiKey}}',
|
||||
},
|
||||
},
|
||||
} as IAuthenticateBearer;
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
IAuthenticateBearer,
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
@@ -17,12 +17,15 @@ export class TwakeCloudApi implements ICredentialType {
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
authenticate = {
|
||||
type: 'bearer',
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
tokenPropertyName: 'workspaceKey',
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.workspaceKey}}',
|
||||
},
|
||||
},
|
||||
} as IAuthenticateBearer;
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
|
||||
Reference in New Issue
Block a user