From c2586557d8b9d97c6b16e46cfcbd2aef458dd956 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 26 Jan 2022 20:45:45 +0100 Subject: [PATCH] root: fix redis passwords not being encoded correctly closes #2130 Signed-off-by: Jens Langhammer --- authentik/root/settings.py | 4 ++-- lifecycle/wait_for_db.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index fc17f16aa..23d569a38 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -18,7 +18,7 @@ from hashlib import sha512 from json import dumps from tempfile import gettempdir from time import time -from urllib.parse import quote +from urllib.parse import quote_plus import structlog from celery.schedules import crontab @@ -220,7 +220,7 @@ if CONFIG.y_bool("redis.tls", False): REDIS_CELERY_TLS_REQUIREMENTS = f"?ssl_cert_reqs={CONFIG.y('redis.tls_reqs')}" _redis_url = ( f"{REDIS_PROTOCOL_PREFIX}:" - f"{quote(CONFIG.y('redis.password'))}@{quote(CONFIG.y('redis.host'))}:" + f"{quote_plus(CONFIG.y('redis.password'))}@{quote_plus(CONFIG.y('redis.host'))}:" f"{int(CONFIG.y('redis.port'))}" ) diff --git a/lifecycle/wait_for_db.py b/lifecycle/wait_for_db.py index 86e3cb80b..7088f070f 100755 --- a/lifecycle/wait_for_db.py +++ b/lifecycle/wait_for_db.py @@ -26,6 +26,8 @@ def j_print(event: str, log_level: str = "info", **kwargs): print(dumps(data), file=stderr) +j_print("Starting authentik bootstrap") + # Sanity check, ensure SECRET_KEY is set before we even check for database connectivity if CONFIG.y("secret_key") is None or len(CONFIG.y("secret_key")) == 0: j_print("----------------------------------------------------------------------") @@ -47,7 +49,9 @@ while True: break except OperationalError as exc: sleep(1) - j_print(f"PostgreSQL Connection failed, retrying... ({exc})") + j_print(f"PostgreSQL connection failed, retrying... ({exc})") + finally: + j_print("PostgreSQL connection successful") REDIS_PROTOCOL_PREFIX = "redis://" if CONFIG.y_bool("redis.tls", False): @@ -65,3 +69,7 @@ while True: except RedisError as exc: sleep(1) j_print(f"Redis Connection failed, retrying... ({exc})", redis_url=REDIS_URL) + finally: + j_print("Redis Connection successful") + +j_print("Finished authentik bootstrap")