Skip to content

Commit fb62096

Browse files
committed
docs: import CloudNativePG main
1 parent f457326 commit fb62096

2 files changed

Lines changed: 58 additions & 1 deletion

File tree

‎website/docs/connection_pooling.md‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ This gives you the flexibility — and responsibility — to manage the
236236
authentication process yourself. You can follow the instructions above to
237237
replicate similar behavior to the default setup.
238238

239+
If PgBouncer needs to authenticate as a different user than the one derived
240+
from your secret, you can override it with the `auth_user` parameter (see
241+
[PgBouncer configuration options](#pgbouncer-configuration-options)).
242+
239243
## Pod templates
240244

241245

@@ -522,7 +526,51 @@ These are the PgBouncer options you can customize, with links to the PgBouncer
522526
documentation for each parameter. Unless stated otherwise, the default values
523527
are the ones directly set by PgBouncer.
524528

525-
- [`auth_type`](https://www.pgbouncer.org/config.html#auth_type)
529+
- [`auth_type`](https://www.pgbouncer.org/config.html#auth_type): the default,
530+
`hba`, resolves each client's authentication method from the Pooler's own
531+
`.spec.pgbouncer.pg_hba` list (not to be confused with the `Cluster`'s
532+
`.spec.postgresql.pg_hba`, which governs PostgreSQL's own client
533+
authentication).
534+
- [`auth_user`](https://www.pgbouncer.org/config.html#auth_user): overrides the
535+
user PgBouncer connects with to run the authentication query. By default it is
536+
derived from the auth query secret (the `username` key for basic-auth secrets,
537+
the certificate common name for TLS secrets). Setting it is meant for setups
538+
with a custom `authQuerySecret`, since the built-in integration provisions
539+
everything for the default `cnpg_pooler_pgbouncer` user; with a basic-auth
540+
secret only the username changes. PgBouncer still uses the secret's password
541+
field to authenticate its own auth_query connection, so that field must
542+
contain the actual PostgreSQL password for the overridden `auth_user` role,
543+
not the password of the secret's original username. An empty value is
544+
ignored. Once you customize the `auth_user`, ensure that the
545+
user exists in PostgreSQL and has the necessary privileges to run the
546+
`auth_query` (see ["Authentication"](#authentication)).
547+
548+
If the auth query secret is certificate-based, overriding `auth_user` only
549+
changes the role PgBouncer requests during the auth query; it does not
550+
change the certificate PgBouncer presents. The operator's built-in
551+
`pg_hba`/`pg_ident` rules only match the literal `cnpg_pooler_pgbouncer`
552+
user, so a custom `auth_user` needs its own `pg_hba` rule and a matching
553+
`pg_ident` entry on the `Cluster` to map the certificate's common name to
554+
the new role (see the [`pg_hba`](postgresql_conf.md#the-pg_hba-section) and
555+
[`pg_ident`](postgresql_conf.md#the-pg_ident-section) sections), for
556+
example:
557+
558+
```yaml
559+
postgresql:
560+
pg_ident:
561+
- poolermap pooler-client-cn pgbouncer
562+
pg_hba:
563+
- hostssl all pgbouncer all cert map=poolermap
564+
```
565+
566+
Without this mapping, the auth_query connection will fail authentication
567+
once `auth_user` no longer matches the certificate identity recognized by
568+
the fixed rules.
569+
570+
PgBouncer only consults `auth_query`/`auth_user` when the client-facing
571+
method resolved by `auth_type` is password-based (`md5`/`scram`); with a
572+
`peer`, `cert`, or `trust` rule in the Pooler's own `pg_hba`, the override
573+
has no effect for that client.
526574
- [`application_name_add_host`](https://www.pgbouncer.org/config.html#application_name_add_host)
527575
- [`autodb_idle_timeout`](https://www.pgbouncer.org/config.html#autodb_idle_timeout)
528576
- [`cancel_wait_timeout`](https://www.pgbouncer.org/config.html#cancel_wait_timeout)

‎website/docs/security.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,15 @@ allows `superuser: true` and membership of any existing role through
323323
access on the PostgreSQL clusters in that namespace, and deserves the same
324324
care as write access to the `Cluster` resource.
325325

326+
A similar consideration applies to the `Pooler` resource: its `authQuery`
327+
field accepts arbitrary SQL that PgBouncer runs against the `postgres`
328+
database to authenticate client connections, and the `auth_user` parameter (see
329+
[Connection Pooling](connection_pooling.md#pgbouncer-configuration-options))
330+
selects the role that query runs as. Write access to a `Pooler` therefore
331+
already implies the ability to run arbitrary SQL as any role for which
332+
PostgreSQL authentication succeeds, and deserves the same care as write
333+
access to the `Cluster` resource.
334+
326335
Treat write access to these resources as a high-privilege grant: for
327336
multi-tenant deployments, isolate tenants in separate namespaces and scope it
328337
per namespace with Kubernetes RBAC, relying on

0 commit comments

Comments
 (0)