Skip to content

With PassthroughAuth set to enabled_plain, changing a user's password prevents new connections from being established #830

@rissson

Description

@rissson

We're running a setup where PostgreSQL passwords are auto-rotated every month, and we found that PgDog doesn't support connecting with a changed password without restarting. I'm suspecting some kind of cache to avoid going back to postgres to validate the new password.

To reproduce

The setup is thus:

# compose.yml
services:
  postgresql:
    image: docker.io/library/postgres:18
    command: "-c log_statement=all"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - 5432:5432
    restart: always
  pgdog:
    image: ghcr.io/pgdogdev/pgdog:v0.1.32
    volumes:
      - ./pgdog.toml:/pgdog/pgdog.toml:ro
    ports:
      - 6432:6432
    restart: always
# pgdog.toml
[general]
host = "[::]"
port = 6432
passthrough_auth = "enabled_plain"
prepared_statements = "extended_anonymous"
pub_sub_channel_size = 8192

[admin]
password = "admin"
[[databases]]
host = "postgresql"
name = "postgres"

After starting the above stack, run the following steps:

Create a user:

PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres postgres -c "create user my_user with password 'first_password'"

Verify it can connect to both PostgreSQL directly and via PgDog:

PGPASSWORD=first_password psql -h localhost -p 5432 -U my_user postgres -c '\q'
PGPASSWORD=first_password psql -h localhost -p 6432 -U my_user postgres -c '\q'

Then change the password of the user via PostgreSQL directly (not sure if that matters):

PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres postgres -c "alter user my_user with password 'second_password'"

Verify the user can still connect directly to PostgreSQL with the new password:

PGPASSWORD=second_password psql -h localhost -p 5432 -U my_user postgres -c '\q'

However, it cannot connect via PgDog anymore:

PGPASSWORD=second_password psql -h localhost -p 6432 -U my_user postgres
psql: error: connection to server at "localhost" (::1), port 6432 failed: FATAL:  password for user "my_user" and database "postgres" is wrong, or the database does not exist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions