Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 apps/medusa/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ ADMIN_BACKEND_URL=http://localhost:9000

# Add your own Stripe secret key here
STRIPE_API_KEY=

DATABASE_SSL_DISABLED=true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Carefully consider this default for production environments.

Adding the DATABASE_SSL_DISABLED=true variable is a good way to make SSL configuration explicit and customizable. However, setting the default to disable SSL in the template file could lead to insecure configurations if this template is used as a starting point for production environments.

Consider either:

  1. Setting the default to false to prioritize security in production
  2. Adding a comment that clearly indicates this setting should be changed for production environments

🏁 Script executed:

#!/bin/bash
# Check if there are any security guidelines or documentation about database connections
find . -type f -name "*.md" | xargs grep -l "database security\|SSL connection\|production configuration" | head -n 5

Length of output: 119


Enforce SSL by default for production
Disabling SSL by default in your template risks insecure DB connections if this file is copied into prod. Please update apps/medusa/.env.template at line 17:

  • File: apps/medusa/.env.template
  • Line: 17

Suggested change (pick one):

- DATABASE_SSL_DISABLED=true
+ # For production, leave SSL enabled. Set this to `true` only in local/dev.
+ DATABASE_SSL_DISABLED=false

Or, if you prefer to keep the default as true for dev, add a clear comment above it:

+ # ⚠️ In production ensure this is set to `false` to enforce SSL
  DATABASE_SSL_DISABLED=true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DATABASE_SSL_DISABLED=true
# For production, leave SSL enabled. Set this to `true` only in local/dev.
DATABASE_SSL_DISABLED=false

6 changes: 2 additions & 4 deletions apps/medusa/medusa-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ loadEnv(process.env.NODE_ENV || 'development', process.cwd());
const REDIS_URL = process.env.REDIS_URL;
const STRIPE_API_KEY = process.env.STRIPE_API_KEY;
const IS_TEST = process.env.NODE_ENV === 'test';
const DATABASE_SSL_DISABLED = process.env.DATABASE_SSL_DISABLED === 'true';

const cacheModule = IS_TEST
? { resolve: '@medusajs/medusa/cache-inmemory' }
Expand Down Expand Up @@ -38,11 +39,8 @@ const workflowEngineModule = IS_TEST
module.exports = defineConfig({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
databaseDriverOptions: {
ssl: false,
},
databaseDriverOptions: DATABASE_SSL_DISABLED ? undefined : { connection: { ssl: { rejectUnauthorized: false } } },
redisUrl: REDIS_URL,

redisPrefix: process.env.REDIS_PREFIX,
http: {
storeCors: process.env.STORE_CORS || '',
Expand Down
2 changes: 1 addition & 1 deletion apps/medusa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@lambdacurry/medusa-product-reviews": "0.0.7",
"@lambdacurry/medusa-product-reviews": "1.1.0",
"@medusajs/admin-sdk": "2.7.0",
"@medusajs/cli": "2.7.0",
"@medusajs/framework": "2.7.0",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3464,9 +3464,9 @@ __metadata:
languageName: node
linkType: hard

"@lambdacurry/medusa-product-reviews@npm:0.0.7":
version: 0.0.7
resolution: "@lambdacurry/medusa-product-reviews@npm:0.0.7"
"@lambdacurry/medusa-product-reviews@npm:1.1.0":
version: 1.1.0
resolution: "@lambdacurry/medusa-product-reviews@npm:1.1.0"
dependencies:
"@hookform/resolvers": "npm:3.4.2"
"@lambdacurry/medusa-plugins-sdk": "npm:0.0.5"
Expand All @@ -3489,7 +3489,7 @@ __metadata:
"@mikro-orm/postgresql": 6.4.3
awilix: ^8.0.1
pg: ^8.13.0
checksum: 10c0/b4c03b461a1cd8ec2796f9660be37e53011a5786fac5a50d42c60e92c0776a0815b16d09af17ee20d0ac3dd75f06f8e5ea36eaf050e736a9385530070713c5e6
checksum: 10c0/b5b1ec69893821f3e83cfb513e16e462935c5b3f9c4b1afe8a5986c78a90e039e65b8760c432da9a545bc223187db965eb27d0ba1bf5e744e9448ac117d50d80
languageName: node
linkType: hard

Expand Down Expand Up @@ -21682,7 +21682,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "medusa@workspace:apps/medusa"
dependencies:
"@lambdacurry/medusa-product-reviews": "npm:0.0.7"
"@lambdacurry/medusa-product-reviews": "npm:1.1.0"
"@medusajs/admin-sdk": "npm:2.7.0"
"@medusajs/cli": "npm:2.7.0"
"@medusajs/framework": "npm:2.7.0"
Expand Down