feat: External Secrets storage for credentials (#6477)

Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Romain Minaud <romain.minaud@gmail.com>
Co-authored-by: Valya Bullions <valya@n8n.io>
Co-authored-by: Csaba Tuncsik <csaba@n8n.io>
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
Alex Grozav
2023-08-25 11:33:46 +03:00
committed by GitHub
parent c833078c87
commit ed927d34b2
89 changed files with 4164 additions and 57 deletions

View File

@@ -157,6 +157,8 @@ import {
getNodeCredentialForSelectedAuthType,
updateNodeAuthType,
isCredentialModalState,
isExpression,
isTestableExpression,
} from '@/utils';
import { externalHooks } from '@/mixins/externalHooks';
@@ -370,12 +372,13 @@ export default defineComponent({
}
const { ownedBy, sharedWith, ...credentialData } = this.credentialData;
const hasExpressions = Object.values(credentialData).reduce(
const hasUntestableExpressions = Object.values(credentialData).reduce(
(accu: boolean, value: CredentialInformation) =>
accu || (typeof value === 'string' && value.startsWith('=')),
accu ||
(typeof value === 'string' && isExpression(value) && !isTestableExpression(value)),
false,
);
if (hasExpressions) {
if (hasUntestableExpressions) {
return false;
}
@@ -445,8 +448,14 @@ export default defineComponent({
return false;
}
if (property.type === 'number' && typeof this.credentialData[property.name] !== 'number') {
return false;
if (property.type === 'number') {
const isExpression =
typeof this.credentialData[property.name] === 'string' &&
this.credentialData[property.name].startsWith('=');
if (typeof this.credentialData[property.name] !== 'number' && !isExpression) {
return false;
}
}
}
return true;
@@ -835,12 +844,17 @@ export default defineComponent({
this.testedSuccessfully = false;
}
const usesExternalSecrets = Object.entries(credentialDetails.data || {}).some(([, value]) =>
/=.*\{\{[^}]*\$secrets\.[^}]+}}.*/.test(`${value}`),
);
const trackProperties: ITelemetryTrackProperties = {
credential_type: credentialDetails.type,
workflow_id: this.workflowsStore.workflowId,
credential_id: credential.id,
is_complete: !!this.requiredPropertiesFilled,
is_new: isNewCredential,
uses_external_secrets: usesExternalSecrets,
};
if (this.isOAuthType) {