@@ -236,6 +236,10 @@ This gives you the flexibility — and responsibility — to manage the
236236authentication process yourself. You can follow the instructions above to
237237replicate 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
522526documentation for each parameter. Unless stated otherwise, the default values
523527are 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)
0 commit comments