feat(pgpm): opt-in authenticated_client role via admin-users bootstrap --client#1344
Merged
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Productionizes the restricted
authenticated_clientrole (prototyped in constructive-db'sproxy/pg-wire-proxytest bootstrap) as an opt-in pgpm primitive. The basebootstrapcommand is unchanged; the client role is only created with the new--clientflag:What the role is: a NOLOGIN, NOBYPASSRLS variant of
authenticatedfor SQL-level proxy clients — it inherits table/schema grants (GRANT authenticated TO authenticated_client) with a server-enforcedstatement_timeout = '15s'baseline (ALTER ROLE ... SET).Deliberately NOT included: grant-level hardening like
REVOKE EXECUTE ON set_config/pg_notify FROM PUBLIC. Those revokes affect every non-superuser role in the database — the app's GraphQL server (jwt.claims injection via set_config) and job workers (pg_notify) depend on both — so they remain a proxy-deployment concern (constructive-dbproxy/pg-wire-proxy/src/deployment.ts+ its test bootstrap), applied only to proxy-facing databases with explicit re-grants.Changes:
RoleMapping(pgpm/types): new optionalauthenticatedClient?: string, default'authenticated_client'inpgpmDefaultsand pgsql-client'sDEFAULT_ROLE_MAPPINGgenerateCreateClientRoleSQL(roles, statementTimeout='15s')inpgpm/core/src/roles— idempotent (IF NOT EXISTS pre-checks + TOCTOU exception handling), same style as the other generatorsPgpmInit.bootstrapClientRole(roles)+--clientflag onpgpm admin-users bootstrapVerified live against
constructiveio/postgres-plus:18: role created NOLOGIN/NOBYPASSRLS, membership granted,statement_timeout=15sapplied, and re-runningbootstrap --clientis a no-op.Link to Devin session: https://app.devin.ai/sessions/b759cb7edaaa42348d402e10a5f4ca4b
Requested by: @pyramation