Encrypt/decrypt app secret variables (#17394)
Closes https://github.com/twentyhq/core-team-issues/issues/1724 From PR https://github.com/twentyhq/twenty/pull/15283, followed same implementation - Introduce EnvironmentModule to provide type safety for env-only variables - Encrypt secret variables - When querying app secret variable, display up to first 5 characters (depending on secret length) then `******`
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
import {
|
||||
ConfigVariables,
|
||||
validate,
|
||||
} from 'src/engine/core-modules/twenty-config/config-variables';
|
||||
import { CONFIG_VARIABLES_INSTANCE_TOKEN } from 'src/engine/core-modules/twenty-config/constants/config-variables-instance-tokens.constants';
|
||||
import { EnvironmentConfigDriver } from 'src/engine/core-modules/twenty-config/drivers/environment-config.driver';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
expandVariables: true,
|
||||
validate,
|
||||
envFilePath: process.env.NODE_ENV === 'test' ? '.env.test' : '.env',
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
EnvironmentConfigDriver,
|
||||
{
|
||||
provide: CONFIG_VARIABLES_INSTANCE_TOKEN,
|
||||
useValue: new ConfigVariables(),
|
||||
},
|
||||
],
|
||||
exports: [EnvironmentConfigDriver],
|
||||
})
|
||||
export class EnvironmentModule {}
|
||||
Reference in New Issue
Block a user