Skip to content

Add an auth read-replica database client#1759

Merged
jakubno merged 14 commits intomainfrom
auth-read-replica-eng-3433
Jan 26, 2026
Merged

Add an auth read-replica database client#1759
jakubno merged 14 commits intomainfrom
auth-read-replica-eng-3433

Conversation

@jakubno
Copy link
Copy Markdown
Member

@jakubno jakubno commented Jan 22, 2026

Note

Introduces a dedicated authdb.Client with Read/Write separation and optional read-replica, and refactors services to use it for auth flows.

  • Infra: Adds postgres-read-replica-connection-string secret and passes AUTH_DB_* env vars in Nomad/API; updates Terraform wiring
  • API: New config AUTH_DB_CONNECTION_STRING, AUTH_DB_READ_REPLICA_CONNECTION_STRING, pool sizing; defaults to POSTGRES_CONNECTION_STRING when unset
  • Refactor: Moves auth-related queries (users, teams, API keys, access tokens) to packages/db/pkg/auth with generated auth/queries; updates handlers, team/db helpers, and caches to use authdb.Client; background UpdateLastTimeUsed
  • DB pkg: Extracts shared pool builder; adds builds.ToMachineInfo; removes direct machineinfo-from-EnvBuild coupling
  • Docker reverse proxy: validates access tokens via authdb.Client
  • Tests/seed: Update test utilities, integration tests, and seed scripts to new clients; add packages/db Makefile seed-db
  • Misc: Go module/deps adjustments and small API job env rearrangement

Written by Cursor Bugbot for commit ddc8fdc. This will update automatically on new commits. Configure here.

@linear
Copy link
Copy Markdown

linear bot commented Jan 22, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ebcccb8f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3
github.com/bits-and-blooms/bitset v1.22.0
github.com/dchest/uniuri v1.2.0
github.com/e2b-dev/infra/packages/db v0.0.0-20251013083250-eb6cd250d671
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wanted to remove the shared dependency on db (it was circular)

}
}

func FromDB(build queries.EnvBuild) MachineInfo {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

moved to db package

Copy link
Copy Markdown
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

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

lgtm, jsut few nits

@jakubno jakubno requested a review from dobrac January 26, 2026 12:24
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@jakubno jakubno enabled auto-merge (squash) January 26, 2026 13:07
@jakubno jakubno merged commit 8e3d179 into main Jan 26, 2026
29 checks passed
@jakubno jakubno deleted the auth-read-replica-eng-3433 branch January 26, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants