mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Add Postgres SSL support
This commit is contained in:
@@ -63,6 +63,34 @@ const config = convict({
|
|||||||
default: 'public',
|
default: 'public',
|
||||||
env: 'DB_POSTGRESDB_SCHEMA'
|
env: 'DB_POSTGRESDB_SCHEMA'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ssl: {
|
||||||
|
ca: {
|
||||||
|
doc: 'SSL certificate authority',
|
||||||
|
format: String,
|
||||||
|
default: '',
|
||||||
|
env: 'DB_POSTGRESDB_SSL_CA',
|
||||||
|
},
|
||||||
|
cert: {
|
||||||
|
doc: 'SSL certificate',
|
||||||
|
format: String,
|
||||||
|
default: '',
|
||||||
|
env: 'DB_POSTGRESDB_SSL_CERT',
|
||||||
|
},
|
||||||
|
key: {
|
||||||
|
doc: 'SSL key',
|
||||||
|
format: String,
|
||||||
|
default: '',
|
||||||
|
env: 'DB_POSTGRESDB_SSL_KEY',
|
||||||
|
},
|
||||||
|
rejectUnauthorized: {
|
||||||
|
doc: 'If unauthorized SSL connections should be rejected',
|
||||||
|
format: 'Boolean',
|
||||||
|
default: true,
|
||||||
|
env: 'DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
mysqldb: {
|
mysqldb: {
|
||||||
database: {
|
database: {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
getRepository,
|
getRepository,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
|
import { TlsOptions } from 'tls';
|
||||||
|
|
||||||
import * as config from '../config';
|
import * as config from '../config';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -72,6 +74,22 @@ export async function init(): Promise<IDatabaseCollections> {
|
|||||||
|
|
||||||
case 'postgresdb':
|
case 'postgresdb':
|
||||||
entities = PostgresDb;
|
entities = PostgresDb;
|
||||||
|
|
||||||
|
const sslCa = await GenericHelpers.getConfigValue('database.postgresdb.ssl.ca') as string;
|
||||||
|
const sslCert = await GenericHelpers.getConfigValue('database.postgresdb.ssl.cert') as string;
|
||||||
|
const sslKey = await GenericHelpers.getConfigValue('database.postgresdb.ssl.key') as string;
|
||||||
|
const sslRejectUnauthorized = await GenericHelpers.getConfigValue('database.postgresdb.ssl.rejectUnauthorized') as boolean;
|
||||||
|
|
||||||
|
let ssl: TlsOptions | undefined = undefined;
|
||||||
|
if (sslCa !== '' || sslCert !== '' || sslKey !== '' || sslRejectUnauthorized !== true) {
|
||||||
|
ssl = {
|
||||||
|
ca: sslCa || undefined,
|
||||||
|
cert: sslCert || undefined,
|
||||||
|
key: sslKey || undefined,
|
||||||
|
rejectUnauthorized: sslRejectUnauthorized,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
connectionOptions = {
|
connectionOptions = {
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
entityPrefix,
|
entityPrefix,
|
||||||
@@ -84,7 +102,9 @@ export async function init(): Promise<IDatabaseCollections> {
|
|||||||
migrations: [InitialMigration1587669153312],
|
migrations: [InitialMigration1587669153312],
|
||||||
migrationsRun: true,
|
migrationsRun: true,
|
||||||
migrationsTableName: `${entityPrefix}migrations`,
|
migrationsTableName: `${entityPrefix}migrations`,
|
||||||
|
ssl,
|
||||||
};
|
};
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mariadb':
|
case 'mariadb':
|
||||||
|
|||||||
Reference in New Issue
Block a user