Sample Header Ad - 728x90

Store LDAP bind credentials in environment variables for pg_hba.conf

0 votes
2 answers
1566 views
I am working on setting up LDAP authentication for a PostgreSQL database and have added the following in my pg_hba.conf file:
# TYPE  DATABASE    USER    ADDRESS     METHOD
host    all         all     all         ldap ldapurl="ldap://example.local/dc=example,dc=local?sAMAccountName" ldapbinddn="username" ldapbindpasswd="password"
It works! But now I'd like to store the username and password as environment variables, like I do for most of my config settings. I've tried adding the username and password as $LDAPUSERNAME or "$LDAPUSERNAME" but they aren't inserting any values. Is this possible? Note: The database will be running in a docker container. If I have to run some script to process the pg_hba.conf file before starting the database, I can.
Asked by GammaGames (105 rep)
Jan 19, 2022, 11:50 PM
Last activity: Jan 21, 2022, 07:14 PM