Skip to content

Support arbitrary libpq connection options in PostgreSQL backend #15559

@D-Tasker207

Description

@D-Tasker207

Problem
Currently we can specify multiple hosts for the postgres backend like this:
AUTHENTIK_POSTGRESQL__HOST=host1,host2,...
but we cannot add arbitrary options like we could if we were provided with a connection URI option. This is causing issues as I am attempting to connect this to a highly available postgres cluster which uses a connection string like that below in order to only connect to the currently active master.
postgres://writer1:5432,writer2:5432,.../exampledb?target_session_attrs=read-write&....

Proposed Solution
Add something like:
AUTHENTIK_POSTGRESQL__DATABASE_OPTIONS='{"target_session_attrs":"read-write", ...}'
To allow users to define arbitrary connection data. Notably this options string should be different between read replicas and main host as, for example in my use case, target_session_attrs=read-write would prevent any read replicas from connecting.

Additional Context
A proof-of-concept implementation is available in this fork:
stazio#1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions