Skip to content

Commit

Permalink
[Github #682] env fix (#683)
Browse files Browse the repository at this point in the history
* [gh-#682] better check for the environment variable NANGO_ENCRYPTION_KEY

* [gh-#682] explicitly set env variables

* [gh-#682] add worker port env variable
  • Loading branch information
khaliqgant authored Jun 22, 2023
1 parent 0ade809 commit f7b8636
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
# NANGO_DB_POOL_MAX=<PICK-INT-OR-SKIP>
#
#
# - Configure server port (current value is the default for running Nango locally).
# - Configure server and worker port (current value is the default for running Nango locally).
#
SERVER_PORT=3003
WORKER_PORT=3004
#
#
# - Configure server full URL (current value is the default for running Nango locally).
Expand Down
29 changes: 27 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,30 @@ services:
environment:
- TEMPORAL_ADDRESS=temporal:7233
- NANGO_DB_MIGRATION_FOLDER=/usr/nango-server/src/packages/shared/lib/db/migrations
- NANGO_SECRET_KEY=${NANGO_SECRET_KEY}
- NANGO_ENCRYPTION_KEY=${NANGO_ENCRYPTION_KEY}
- NANGO_DB_USER=${NANGO_DB_USER}
- NANGO_DB_PASSWORD=${NANGO_DB_PASSWORD}
- NANGO_DB_HOST=${NANGO_DB_HOST}
- NANGO_DB_NAME=${NANGO_DB_NAME}
- NANGO_DB_SSL=${NANGO_DB_SSL}
- NANGO_DB_POOL_MIN=${NANGO_DB_POOL_MIN}
- NANGO_DB_POOL_MAX=${NANGO_DB_POOL_MAX}
- SERVER_PORT=${SERVER_PORT}
- NANGO_SERVER_URL=${NANGO_SERVER_URL:-http://localhost:3003}
- NANGO_CALLBACK_URL=${NANGO_CALLBACK_URL}
- NANGO_DASHBOARD_USERNAME=${NANGO_DASHBOARD_USERNAME}
- NANGO_DASHBOARD_PASSWORD=${NANGO_DASHBOARD_PASSWORD}
- LOG_LEVEL=${LOG_LEVEL:-info}
- TELEMETRY=${TELEMETRY}
- NANGO_HMAC_ENABLED=${NANGO_HMAC_ENABLED}
- NANGO_HMAC_ALGORITHM=${NANGO_HMAC_ALGORITHM}
- NANGO_HMAC_KEY=${NANGO_HMAC_KEY}
volumes:
- './packages/shared/providers.yaml:/usr/nango-server/src/packages/shared/providers.yaml'
restart: always
ports:
- '3003:3003'
- '${SERVER_PORT:-3003}:${SERVER_PORT:-3003}'
depends_on:
- nango-db
networks:
Expand All @@ -35,9 +54,15 @@ services:
container_name: nango-worker
restart: always
ports:
- '3004:3004'
- '${WORKER_PORT:-3004}:${WORKER_PORT:-3004}'
environment:
- TEMPORAL_ADDRESS=temporal:7233
- NANGO_ENCRYPTION_KEY=${NANGO_ENCRYPTION_KEY}
- NANGO_DB_USER=${NANGO_DB_USER}
- NANGO_DB_PASSWORD=${NANGO_DB_PASSWORD}
- NANGO_DB_HOST=${NANGO_DB_HOST}
- NANGO_DB_NAME=${NANGO_DB_NAME}
- NANGO_DB_SSL=${NANGO_DB_SSL}
depends_on:
- nango-db
- temporal
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/utils/encryption.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class EncryptionManager {
constructor(key: string | undefined) {
this.key = key;

if (key != null && Buffer.from(key, this.encoding).byteLength != this.encryptionKeyByteLength) {
if (key && Buffer.from(key, this.encoding).byteLength != this.encryptionKeyByteLength) {
throw new Error('Encryption key must be base64-encoded and 256-bit long.');
}

logger.info(key == null ? 'πŸ”“ Encryption disabled (no encryption key has been set).' : 'πŸ” Encryption enabled!');
logger.info(!key ? 'πŸ”“ Encryption disabled (no encryption key has been set).' : 'πŸ” Encryption enabled!');
}

private shouldEncrypt(): boolean {
Expand Down

0 comments on commit f7b8636

Please sign in to comment.