Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: allow for postgres ssl connections #607

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

Open
JGaudette wants to merge 2 commits into rybbit-io:master
base: master
Choose a base branch
Loading
from JGaudette:feature/ssl-env-variable

Conversation

Copy link

@JGaudette JGaudette commented Sep 29, 2025
edited by coderabbitai bot
Loading

We use RDS and require an ssl connection in our environment. This PR still defaults the ssl mode to false for backwards compatibility, but also introduced an environment variable to overwrite that and enable SSL mode on the postgres connection.

Summary by CodeRabbit

  • New Features
    • Optional PostgreSQL SSL support configurable via POSTGRES_SSL; backend will respect this setting to enable/disable SSL for database connections.
  • Documentation
    • Updated self-hosting guidance to document POSTGRES_SSL and its default behavior.
  • Chores
    • Added POSTGRES_SSL to example environment configuration and cloud deployment configuration.

Copy link

vercel bot commented Sep 29, 2025

@JGaudette is attempting to deploy a commit to the goldflag's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Sep 29, 2025
edited
Loading

Walkthrough

Introduces a POSTGRES_SSL environment variable across config, deployment, and docs. Backend Postgres client (drizzle and postgres client) now enables SSL only when POSTGRES_SSL == "true". Adds the variable to .env.example and docker-compose.cloud.yml, and documents it in self-hosting-advanced.mdx.

Changes

Cohort / File(s) Summary of Changes
Environment samples & docs
./.env.example, docs/src/content/self-hosting-advanced.mdx
Added POSTGRES_SSL with default false to the example env and documentation.
Deployment (cloud compose)
./docker-compose.cloud.yml
Injected POSTGRES_SSL (default false) into the backend service environment.
Server DB configuration (drizzle)
server/drizzle.config.ts
Made ssl conditional: ssl is true only when process.env.POSTGRES_SSL === "true", otherwise false.
Server DB client init
server/src/db/postgres/postgres.ts
Added ssl: process.env.POSTGRES_SSL === "true" ? true : false to the Postgres client connection options.

Sequence Diagram(s)

sequenceDiagram
 autonumber
 participant Admin as Operator/Admin
 participant Backend as Backend (Drizzle / PG client)
 participant PG as PostgreSQL
 Admin->>Backend: Set env POSTGRES_SSL=("true"|"false")
 Note right of Backend: process.env.POSTGRES_SSL read during startup
 alt POSTGRES_SSL == "true"
 Backend->>PG: Connect with SSL enabled
 PG-->>Backend: Connection established (SSL)
 else POSTGRES_SSL != "true"
 Backend->>PG: Connect without SSL
 PG-->>Backend: Connection established (non-SSL)
 end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I’m a rabbit in the config glade,
toggling SSL like a carrot trade.
Env, compose, and docs all sing,
Drizzle and client take the swing.
True for secure, false for light-footed play. 🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: allow for postgres ssl connections" succinctly and accurately describes the primary change of the pull request, which is to introduce an environment-variable-driven option for enabling SSL on PostgreSQL connections; it follows conventional commit styling and clearly communicates the feature being added without unnecessary detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.env.example (1)

26-26: Consider reordering for consistency.

The static analysis tool suggests placing POSTGRES_SSL before POSTGRES_USER to maintain alphabetical ordering within the PostgreSQL configuration section.

Apply this diff to reorder the keys:

 # PostgreSQL Database Configuration
 POSTGRES_DB=analytics
+POSTGRES_SSL=false
 POSTGRES_USER=frog
 POSTGRES_PASSWORD=frog
-POSTGRES_SSL=false
server/drizzle.config.ts (1)

16-16: Simplify the boolean expression.

The ternary operator is redundant since the equality check already returns a boolean.

Apply this diff to simplify:

- ssl: process.env.POSTGRES_SSL === "true" ? true : false,
+ ssl: process.env.POSTGRES_SSL === "true",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 331e5c8 and a1990dd.

📒 Files selected for processing (4)
  • .env.example (1 hunks)
  • docker-compose.cloud.yml (1 hunks)
  • docs/src/content/self-hosting-advanced.mdx (1 hunks)
  • server/drizzle.config.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{client,server}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

{client,server}/**/*.{ts,tsx}: Use TypeScript with strict typing throughout both client and server
Use try/catch blocks with specific error types for error handling
Use camelCase for variables and functions, PascalCase for components and types
Group imports by external, then internal, and sort alphabetically within groups

Files:

  • server/drizzle.config.ts
server/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Backend: Use Fastify, Drizzle ORM (Postgres), ClickHouse, and Zod

Files:

  • server/drizzle.config.ts
🪛 dotenv-linter (3.3.0)
.env.example

[warning] 26-26: [UnorderedKey] The POSTGRES_SSL key should go before the POSTGRES_USER key

(UnorderedKey)

🔇 Additional comments (2)
docs/src/content/self-hosting-advanced.mdx (1)

70-70: LGTM!

The documentation correctly reflects the new POSTGRES_SSL environment variable with the appropriate default value for backwards compatibility.

docker-compose.cloud.yml (1)

89-89: LGTM!

The environment variable is correctly configured with a sensible default, maintaining backwards compatibility while allowing SSL to be enabled when needed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
server/src/db/postgres/postgres.ts (1)

15-15: Simplify the redundant ternary expression.

The expression process.env.POSTGRES_SSL === "true" ? true : false can be simplified.

Apply this diff to simplify:

- ssl: process.env.POSTGRES_SSL === "true" ? true : false,
+ ssl: process.env.POSTGRES_SSL === "true",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1990dd and 2d308ce.

📒 Files selected for processing (1)
  • server/src/db/postgres/postgres.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{client,server}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

{client,server}/**/*.{ts,tsx}: Use TypeScript with strict typing throughout both client and server
Use try/catch blocks with specific error types for error handling
Use camelCase for variables and functions, PascalCase for components and types
Group imports by external, then internal, and sort alphabetically within groups

Files:

  • server/src/db/postgres/postgres.ts
server/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Backend: Use Fastify, Drizzle ORM (Postgres), ClickHouse, and Zod

Files:

  • server/src/db/postgres/postgres.ts

database: process.env.POSTGRES_DB,
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
ssl: process.env.POSTGRES_SSL === "true" ? true : false,
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 30, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Consider SSL certificate validation for production environments.

While enabling SSL with ssl: true encrypts the connection, it doesn't validate the server's certificate by default. For production environments like RDS, you should verify the server certificate to prevent man-in-the-middle attacks.

Consider using an object configuration for SSL to enable certificate validation:

- ssl: process.env.POSTGRES_SSL === "true" ? true : false,
+ ssl: process.env.POSTGRES_SSL === "true" ? { rejectUnauthorized: true } : false,

Note: RDS instances typically require certificate validation. If you need to provide a custom CA certificate, the postgres library also supports:

ssl: {
 rejectUnauthorized: true,
 ca: fs.readFileSync('/path/to/ca-certificate.crt').toString(),
}
🤖 Prompt for AI Agents
In server/src/db/postgres/postgres.ts around line 15, the SSL option is
currently set as a boolean which enables encryption but does not enforce server
certificate validation; change the ssl option to an object that sets
rejectUnauthorized: true for production (e.g., when NODE_ENV === "production" or
POSTGRES_SSL === "true") and, if required by your RDS setup, load a CA bundle
from a configured path (read the CA file with fs.readFileSync and pass it as
ca); ensure you conditionally construct this object (or leave ssl: false for
non-SSL envs), and add the needed fs import and error handling for missing CA
file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /