Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joyous #4

Merged
merged 49 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8e6d834
allow execution on node 19,20,22
eyalfishler May 19, 2023
4b0e9b4
Added procfile
omrijoyous May 22, 2023
5c576d4
Added procfile
omrijoyous May 22, 2023
eab8522
redployed
omrijoyous May 22, 2023
12625e0
redployed
omrijoyous May 22, 2023
226d55a
redployed
omrijoyous May 22, 2023
a077a75
redployed
omrijoyous May 22, 2023
2573412
redployed
omrijoyous May 22, 2023
51a176b
redployed
omrijoyous May 22, 2023
e8aad7c
dont start
eyalfishler May 22, 2023
accbdd0
redployed
omrijoyous May 22, 2023
c3061d5
redployed
omrijoyous May 22, 2023
c249585
update version
eyalfishler May 22, 2023
c33f204
redployed
omrijoyous May 22, 2023
c46cf72
redployed
omrijoyous May 22, 2023
d490bf8
redployed
omrijoyous May 22, 2023
9c4321d
redployed
omrijoyous May 22, 2023
13e7bb6
Revert "update version"
omrijoyous May 22, 2023
db4f729
add heroku stack version
eyalfishler May 22, 2023
8b2608b
delete
eyalfishler May 22, 2023
5de916a
add app.json setting heroku build stack
eyalfishler May 22, 2023
42fa907
update
eyalfishler May 22, 2023
7e688b6
update vite
eyalfishler May 22, 2023
4e462e0
update mem
eyalfishler May 22, 2023
485df71
update PORT
eyalfishler May 22, 2023
80b09a9
redployed
omrijoyous May 23, 2023
ffa081e
Merge pull request #1 from n8n-io/master
May 23, 2023
c75967d
updated redis to use ssl
omrijoyous May 23, 2023
b4fdfad
updated redis to use ssl
omrijoyous May 23, 2023
2784edc
updated redis to use ssl
omrijoyous May 23, 2023
66f35d3
updated redis to use ssl
omrijoyous May 23, 2023
22fffa3
using redis and postgres from process.env
omrijoyous May 24, 2023
732ec33
using redis and postgres from process.env
omrijoyous May 24, 2023
02982ad
using redis and postgres from process.env
omrijoyous May 24, 2023
d00e686
using redis and postgres from process.env
omrijoyous May 24, 2023
8c16501
Enabled enterprise
omrijoyous May 24, 2023
b36b9d1
Merge branch 'n8n-io:master' into joyous
omrijoyous May 24, 2023
c97cf42
Disabled a few functions
omrijoyous May 24, 2023
f5e37a7
small changes in schema
omrijoyous May 25, 2023
752455b
Make sure we dont turn on ssl when redis runs in local mode
omrijoyous May 25, 2023
214dd13
Updated proc file to run worker
omrijoyous May 25, 2023
e4a0eb2
Renamed procfile
omrijoyous May 25, 2023
4b9a1f6
Redis Worker should use env var
omrijoyous May 25, 2023
00de552
Redis Worker should use tls remotely
omrijoyous May 25, 2023
0d8f68c
Making sure we dont use ssl when working with postgres locally
omrijoyous May 30, 2023
6eda22a
Merge branch 'n8n-io:master' into joyous
omrijoyous May 30, 2023
515e040
Merge branch 'master' into joyous
omrijoyous May 30, 2023
55540a5
Enabled Sharing
omrijoyous May 30, 2023
7b2b10b
Disabled telemetry
omrijoyous May 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ packages/**/.turbo
cypress/videos/*
cypress/screenshots/*
*.swp
.env
.env.local
1 change: 0 additions & 1 deletion PROCFILE

This file was deleted.

2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: npm start
worker: npm start worker
16 changes: 12 additions & 4 deletions packages/cli/src/AbstractServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import bodyParserXml from 'body-parser-xml';
import compression from 'compression';
import parseUrl from 'parseurl';
import type { RedisOptions } from 'ioredis';
import { parseRedisUrl } from '@/ParserHelper'

import type { WebhookHttpMethod } from 'n8n-workflow';
import { LoggerProxy as Logger } from 'n8n-workflow';
Expand Down Expand Up @@ -188,14 +189,15 @@ export abstract class AbstractServer {

let lastTimer = 0;
let cumulativeTimeout = 0;
const { host, port, username, password, db }: RedisOptions = config.getEnv('queue.bull.redis');
let tlsConfig = {};
const { host, port, password, db}: RedisOptions = parseRedisUrl() || config.getEnv('queue.bull.redis');
const redisConnectionTimeoutLimit = config.getEnv('queue.bull.redis.timeoutThreshold');
Logger.debug(`Redis is configured to: host: ${host}, port: ${port}, db: ${db}`);

const redis = new Redis({
let redisConfig: RedisOptions = {
host,
port,
db,
username,
password,
retryStrategy: (): number | null => {
const now = Date.now();
Expand All @@ -215,7 +217,13 @@ export abstract class AbstractServer {
}
return 500;
},
});
}

if ( host !== 'localhost' && '127.0.0.1' ) {
// If redis is in localhost mode then there is no need to configre any ssl options
redisConfig['tls'] = { rejectUnauthorized: false }
}
const redis = new Redis(redisConfig);

redis.on('close', () => {
Logger.warn('Redis unavailable - trying to reconnect...');
Expand Down
41 changes: 28 additions & 13 deletions packages/cli/src/Db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
WorkflowStatisticsRepository,
WorkflowTagMappingRepository,
} from '@db/repositories';
import { parsePostgresUrl } from './ParserHelper';

export const collections = {} as IDatabaseCollections;

Expand Down Expand Up @@ -89,20 +90,23 @@ export async function transaction<T>(fn: (entityManager: EntityManager) => Promi
export function getConnectionOptions(dbType: DatabaseType): ConnectionOptions {
switch (dbType) {
case 'postgresdb':
const sslCa = config.getEnv('database.postgresdb.ssl.ca');
const sslCert = config.getEnv('database.postgresdb.ssl.cert');
const sslKey = config.getEnv('database.postgresdb.ssl.key');
const sslRejectUnauthorized = config.getEnv('database.postgresdb.ssl.rejectUnauthorized');
process.env['PGSSLMODE'] = 'require';

let ssl: TlsOptions | undefined;
if (sslCa !== '' || sslCert !== '' || sslKey !== '' || !sslRejectUnauthorized) {
ssl = {
ca: sslCa || undefined,
cert: sslCert || undefined,
key: sslKey || undefined,
rejectUnauthorized: sslRejectUnauthorized,
};

if (!isPostgresRunningLocally()) {
const sslCa = config.getEnv('database.postgresdb.ssl.ca');
const sslCert = config.getEnv('database.postgresdb.ssl.cert');
const sslKey = config.getEnv('database.postgresdb.ssl.key');
const sslRejectUnauthorized = config.getEnv('database.postgresdb.ssl.rejectUnauthorized');
process.env['PGSSLMODE'] = 'require';

if (sslCa !== '' || sslCert !== '' || sslKey !== '' || !sslRejectUnauthorized) {
ssl = {
ca: sslCa || undefined,
cert: sslCert || undefined,
key: sslKey || undefined,
rejectUnauthorized: sslRejectUnauthorized,
};
}
}

return {
Expand Down Expand Up @@ -206,3 +210,14 @@ export const close = async () => {

if (connection.isInitialized) await connection.destroy();
};

function isPostgresRunningLocally(): Boolean {
let host: String | undefined;
const postgresConfig = parsePostgresUrl();
if (postgresConfig != null) {
host = postgresConfig.host;
} else {
host = config.getEnv('database.postgresdb.host')
}
return (host === ('localhost' || '127.0.0.1'));
}
4 changes: 2 additions & 2 deletions packages/cli/src/License.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ export class License {
}

isLdapEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.LDAP);
return true;
}

isSamlEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.SAML);
return true;
}

isAdvancedExecutionFiltersEnabled() {
Expand Down
39 changes: 39 additions & 0 deletions packages/cli/src/ParserHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { RedisOptions } from 'ioredis';
import { LoggerProxy as Logger } from 'n8n-workflow';
import { URL } from 'url';
import config from '@/config';

export function parseRedisUrl(): RedisOptions | null{
const redisUri = process.env.REDIS_URL;
if (redisUri) {
const parsedURL = new URL(redisUri);
Logger.debug(`Global Redis is configured`);
return {
host: parsedURL.hostname,
port: parseInt(parsedURL.port),
password: parsedURL.password,
db: config.getEnv('queue.bull.redis.db')
}
} else {
Logger.debug(`Global Redis is not configured, working with specific environment variables`);
return null;
}
}

export function parsePostgresUrl(): any {
const postgresUri = process.env.DATABASE_URL;
if (postgresUri) {
const parsedURL = new URL(postgresUri);
Logger.debug(`Global Postgres is configured`);
return {
database: parsedURL.pathname.slice(1),
username: parsedURL.username,
password: parsedURL.password,
host: parsedURL.hostname,
port: parseInt(parsedURL.port),
}
} else {
Logger.debug(`Global Postgres is not configured, working with specific environment variables`);
return null;
}
}
7 changes: 6 additions & 1 deletion packages/cli/src/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { IExecuteResponsePromiseData } from 'n8n-workflow';
import config from '@/config';
import { ActiveExecutions } from '@/ActiveExecutions';
import * as WebhookHelpers from '@/WebhookHelpers';
import { parseRedisUrl } from './ParserHelper';

export type JobId = Bull.JobId;
export type Job = Bull.Job<JobData>;
Expand Down Expand Up @@ -32,7 +33,11 @@ export class Queue {

async init() {
const prefix = config.getEnv('queue.bull.prefix');
const redisOptions: RedisOptions = config.getEnv('queue.bull.redis');
const redisOptions: RedisOptions = parseRedisUrl() ||config.getEnv('queue.bull.redis');
if ( redisOptions.host !== 'localhost' && '127.0.0.1' ) {
// If redis is in localhost mode then there is no need to configre any ssl options
redisOptions['tls'] = { rejectUnauthorized: false }
}

// eslint-disable-next-line @typescript-eslint/naming-convention
const { default: Bull } = await import('bull');
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ export class Server extends AbstractServer {
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
},
enterprise: {
sharing: false,
ldap: false,
saml: false,
logStreaming: false,
advancedExecutionFilters: false,
variables: false,
versionControl: false,
sharing: true,
ldap: true,
saml: true,
logStreaming: true,
advancedExecutionFilters: true,
variables: true,
versionControl: true,
},
hideUsagePage: config.getEnv('hideUsagePage'),
license: {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/UserManagement/UserManagementHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export function isUserManagementEnabled(): boolean {
}

export function isSharingEnabled(): boolean {
const license = Container.get(License);
return isUserManagementEnabled() && license.isSharingEnabled();
return true;
}

export async function getRoleId(scope: Role['scope'], name: Role['name']): Promise<Role['id']> {
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const schema = {
enabled: {
doc: 'Typeorm logging enabled flag.',
format: Boolean,
default: false,
default: true,
env: 'DB_LOGGING_ENABLED',
},
options: {
Expand Down Expand Up @@ -97,7 +97,7 @@ export const schema = {
schema: {
doc: 'PostgresDB Schema',
format: String,
default: 'public',
default: 'n8n',
env: 'DB_POSTGRESDB_SCHEMA',
},

Expand All @@ -123,7 +123,7 @@ export const schema = {
rejectUnauthorized: {
doc: 'If unauthorized SSL connections should be rejected',
format: 'Boolean',
default: true,
default: false,
env: 'DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED',
},
},
Expand Down Expand Up @@ -1056,7 +1056,7 @@ export const schema = {
enabled: {
doc: 'Whether diagnostic mode is enabled.',
format: Boolean,
default: true,
default: false,
env: 'N8N_DIAGNOSTICS_ENABLED',
},
config: {
Expand Down
37 changes: 29 additions & 8 deletions packages/cli/src/databases/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ import { postgresMigrations } from './migrations/postgresdb';
import { sqliteMigrations } from './migrations/sqlite';
import type { DatabaseType } from '@db/types';
import config from '@/config';
import { parsePostgresUrl } from '@/ParserHelper';
import { LoggerProxy as Logger } from 'n8n-workflow';

const entitiesDir = path.resolve(__dirname, 'entities');

const getDBConnectionOptions = (dbType: DatabaseType) => {
const entityPrefix = config.getEnv('database.tablePrefix');
const migrationsDir = path.resolve(__dirname, 'migrations', dbType);
const configDBType = dbType === 'mariadb' ? 'mysqldb' : dbType;
const connectionDetails =
let connectionDetails;

if (dbType == 'postgresdb') {
connectionDetails = parsePostgresUrl();
}
if (!connectionDetails) {
connectionDetails =
configDBType === 'sqlite'
? {
database: path.resolve(
Expand All @@ -32,6 +40,10 @@ const getDBConnectionOptions = (dbType: DatabaseType) => {
host: config.getEnv(`database.${configDBType}.host`),
port: config.getEnv(`database.${configDBType}.port`),
};
} else {
Logger.debug(`Postgres is configured globally to: host: ${connectionDetails.host}, port: ${connectionDetails.port}, db: ${connectionDetails.database}`);
}

return {
entityPrefix,
entities: Object.values(entities),
Expand All @@ -41,13 +53,22 @@ const getDBConnectionOptions = (dbType: DatabaseType) => {
};
};

export const getOptionOverrides = (dbType: 'postgresdb' | 'mysqldb') => ({
database: config.getEnv(`database.${dbType}.database`),
host: config.getEnv(`database.${dbType}.host`),
port: config.getEnv(`database.${dbType}.port`),
username: config.getEnv(`database.${dbType}.user`),
password: config.getEnv(`database.${dbType}.password`),
});
export const getOptionOverrides = (dbType: 'postgresdb' | 'mysqldb') => {
let connectionDetails;
if (dbType == 'postgresdb') {
connectionDetails = parsePostgresUrl();
}
if (!connectionDetails) {
connectionDetails = {
database: config.getEnv(`database.${dbType}.database`),
host: config.getEnv(`database.${dbType}.host`),
port: config.getEnv(`database.${dbType}.port`),
username: config.getEnv(`database.${dbType}.user`),
password: config.getEnv(`database.${dbType}.password`),
}
}
return connectionDetails;
}

export const getSqliteConnectionOptions = (): SqliteConnectionOptions => ({
type: 'sqlite',
Expand Down
16 changes: 8 additions & 8 deletions packages/editor-ui/src/__tests__/server/endpoints/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const defaultSettings: IN8nUISettings = {
endpointWebhook: '',
endpointWebhookTest: '',
enterprise: {
sharing: false,
ldap: false,
saml: false,
logStreaming: false,
advancedExecutionFilters: false,
sharing: true,
ldap: true,
saml: true,
logStreaming: true,
advancedExecutionFilters: true,
variables: true,
versionControl: false,
versionControl: true,
},
executionMode: 'regular',
executionTimeout: 0,
Expand Down Expand Up @@ -44,8 +44,8 @@ const defaultSettings: IN8nUISettings = {
saveDataSuccessExecution: 'DEFAULT',
saveManualExecutions: false,
sso: {
ldap: { loginEnabled: false, loginLabel: '' },
saml: { loginEnabled: false, loginLabel: '' },
ldap: { loginEnabled: true, loginLabel: '' },
saml: { loginEnabled: true, loginLabel: '' },
},
telemetry: {
enabled: false,
Expand Down
22 changes: 11 additions & 11 deletions packages/editor-ui/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const SETTINGS_STORE_DEFAULT_STATE: ISettingsState = {
endpointWebhook: '',
endpointWebhookTest: '',
enterprise: {
advancedExecutionFilters: false,
sharing: false,
ldap: false,
saml: false,
logStreaming: false,
variables: false,
versionControl: false,
advancedExecutionFilters: true,
sharing: true,
ldap: true,
saml: true,
logStreaming: true,
variables: true,
versionControl: true,
},
executionMode: 'regular',
executionTimeout: 0,
Expand Down Expand Up @@ -72,8 +72,8 @@ export const SETTINGS_STORE_DEFAULT_STATE: ISettingsState = {
saveDataSuccessExecution: 'all',
saveManualExecutions: false,
sso: {
ldap: { loginEnabled: false, loginLabel: '' },
saml: { loginEnabled: false, loginLabel: '' },
ldap: { loginEnabled: true, loginLabel: '' },
saml: { loginEnabled: true, loginLabel: '' },
},
telemetry: { enabled: false },
templates: { enabled: false, host: '' },
Expand Down Expand Up @@ -123,11 +123,11 @@ export const SETTINGS_STORE_DEFAULT_STATE: ISettingsState = {
},
ldap: {
loginLabel: '',
loginEnabled: false,
loginEnabled: true,
},
saml: {
loginLabel: '',
loginEnabled: false,
loginEnabled: true,
},
onboardingCallPromptEnabled: false,
saveDataErrorExecution: 'all',
Expand Down
Loading