Merge pull request #22 from pks-t/pks-auth-user-and-query

Support `auth_user` and `auth_query` options
This commit is contained in:
Javier J. Salmerón-García
2021-12-07 17:20:34 +01:00
committed by GitHub
3 changed files with 10 additions and 0 deletions

View File

@@ -217,12 +217,16 @@ pgbouncer_initialize() {
if [[ "$PGBOUNCER_DATABASE" != "*" ]]; then
database_value+=" dbname=$POSTGRESQL_DATABASE"
fi
if ! is_empty_value "$PGBOUNCER_AUTH_USER"; then
database_value+=" auth_user=$PGBOUNCER_AUTH_USER"
fi
ini-file set --section "databases" --key "$PGBOUNCER_DATABASE" --value "$database_value" "$PGBOUNCER_CONF_FILE"
local -r -a key_value_pairs=(
"listen_port:${PGBOUNCER_PORT}"
"listen_addr:${PGBOUNCER_LISTEN_ADDRESS}"
"auth_file:${PGBOUNCER_AUTH_FILE}"
"auth_type:${PGBOUNCER_AUTH_TYPE}"
"auth_query:${PGBOUNCER_AUTH_QUERY}"
"pidfile:${PGBOUNCER_PID_FILE}"
"logfile:${PGBOUNCER_LOG_FILE}"
"admin_users:${POSTGRESQL_USERNAME}"

View File

@@ -25,6 +25,8 @@ pgbouncer_env_vars=(
PGBOUNCER_PORT
PGBOUNCER_LISTEN_ADDRESS
PGBOUNCER_AUTH_TYPE
PGBOUNCER_AUTH_USER
PGBOUNCER_AUTH_QUERY
PGBOUNCER_POOL_MODE
PGBOUNCER_INIT_SLEEP_TIME
PGBOUNCER_INIT_MAX_RETRIES
@@ -89,6 +91,8 @@ export PGBOUNCER_DATABASE="${PGBOUNCER_DATABASE:-postgres}"
export PGBOUNCER_PORT="${PGBOUNCER_PORT:-6432}"
export PGBOUNCER_LISTEN_ADDRESS="${PGBOUNCER_LISTEN_ADDRESS:-0.0.0.0}"
export PGBOUNCER_AUTH_TYPE="${PGBOUNCER_AUTH_TYPE:-md5}"
export PGBOUNCER_AUTH_USER="${PGBOUNCER_AUTH_USER:-}"
export PGBOUNCER_AUTH_QUERY="${PGBOUNCER_AUTH_QUERY:-}"
export PGBOUNCER_POOL_MODE="${PGBOUNCER_POOL_MODE:-}"
export PGBOUNCER_INIT_SLEEP_TIME="${PGBOUNCER_INIT_SLEEP_TIME:-10}"
export PGBOUNCER_INIT_MAX_RETRIES="${PGBOUNCER_INIT_MAX_RETRIES:-10}"

View File

@@ -114,6 +114,8 @@ To expose the same database name as the backend, set `PGBOUNCER_DATABASE="$POSTG
### Other options
- `PGBOUNCER_AUTH_USER`: PgBouncer will use this user to connect to the database and query the PostgreSQL backend for a user and password. Default: **disabled**.
- `PGBOUNCER_AUTH_QUERY`: PgBouncer will use this query to connect to the database and query the PostgreSQL backend for a user and password. Default: **disabled**.
- `PGBOUNCER_POOL_MODE` : PgBouncer pool mode. Allowed values: session, transaction and statement. Default: **session**.
- `PGBOUNCER_INIT_SLEEP_TIME` : PgBouncer initialization sleep time. Default: **10**.
- `PGBOUNCER_INIT_MAX_RETRIES` : PgBouncer initialization maximum retries. Default: **10**.