mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: Hide credentials password values (#4868)
* feat: redact password field values in credentials * feat: disable expanding password fields * fix: redacting credentials without a valid type This only seems to be a thing in testing?
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import express from 'express';
|
||||
import { INodeCredentialTestResult, LoggerProxy } from 'n8n-workflow';
|
||||
import { deepCopy, INodeCredentialTestResult, LoggerProxy } from 'n8n-workflow';
|
||||
import * as Db from '@/Db';
|
||||
import { InternalHooksManager } from '@/InternalHooksManager';
|
||||
import * as ResponseHelper from '@/ResponseHelper';
|
||||
@@ -91,7 +91,10 @@ EECredentialsController.get(
|
||||
const { id, data: _, ...rest } = credential;
|
||||
|
||||
const key = await EECredentials.getEncryptionKey();
|
||||
const decryptedData = await EECredentials.decrypt(key, credential);
|
||||
const decryptedData = EECredentials.redact(
|
||||
await EECredentials.decrypt(key, credential),
|
||||
credential,
|
||||
);
|
||||
|
||||
// @TODO_TECH_DEBT: Stringify `id` with entity field transformer
|
||||
return { id: id.toString(), data: decryptedData, ...rest };
|
||||
@@ -112,8 +115,8 @@ EECredentialsController.post(
|
||||
|
||||
const { ownsCredential } = await EECredentials.isOwned(req.user, credentials.id.toString());
|
||||
|
||||
const sharing = await EECredentials.getSharing(req.user, credentials.id);
|
||||
if (!ownsCredential) {
|
||||
const sharing = await EECredentials.getSharing(req.user, credentials.id);
|
||||
if (!sharing) {
|
||||
throw new ResponseHelper.UnauthorizedError(`Forbidden`);
|
||||
}
|
||||
@@ -122,7 +125,13 @@ EECredentialsController.post(
|
||||
Object.assign(credentials, { data: decryptedData });
|
||||
}
|
||||
|
||||
return EECredentials.test(req.user, encryptionKey, credentials);
|
||||
const mergedCredentials = deepCopy(credentials);
|
||||
if (mergedCredentials.data && sharing?.credentials) {
|
||||
const decryptedData = await EECredentials.decrypt(encryptionKey, sharing.credentials);
|
||||
mergedCredentials.data = EECredentials.unredact(mergedCredentials.data, decryptedData);
|
||||
}
|
||||
|
||||
return EECredentials.test(req.user, encryptionKey, mergedCredentials);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user