Browse Source

Merge pull request #9610 from nocodb/fix/encrypt-integratio-on-init

fix: Integration encryption - handle stringified config value
pull/9612/head
Pranav C 2 months ago committed by GitHub
parent
commit
1cdbc726ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      packages/nocodb/src/helpers/initDataSourceEncryption.ts
  2. 7
      packages/nocodb/src/utils/encryptDecrypt.ts

2
packages/nocodb/src/helpers/initDataSourceEncryption.ts

@ -75,7 +75,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
// check if valid json, if not warn and skip // check if valid json, if not warn and skip
try { try {
JSON.parse(integrations.config); JSON.parse(integration.config);
} catch (e) { } catch (e) {
logger.warn('Invalid JSON in integration config', integration.title); logger.warn('Invalid JSON in integration config', integration.title);
successStatus.push(false); successStatus.push(false);

7
packages/nocodb/src/utils/encryptDecrypt.ts

@ -19,11 +19,14 @@ export const encryptPropIfRequired = ({
return; return;
} }
const val =
typeof data[prop] === 'string' ? data[prop] : JSON.stringify(data[prop]);
if (!secret) { if (!secret) {
return JSON.stringify(data[prop]); return val;
} }
return CryptoJS.AES.encrypt(JSON.stringify(data[prop]), secret).toString(); return CryptoJS.AES.encrypt(val, secret).toString();
}; };
export const decryptPropIfRequired = ({ export const decryptPropIfRequired = ({

Loading…
Cancel
Save