From 5cfbb0993a5e553fbb201d8b2acf30528a9a826e Mon Sep 17 00:00:00 2001 From: Starz0r Date: Mon, 12 Jul 2021 04:01:41 -0500 Subject: [PATCH] Allow for Configurable Redis Port (#1124) * root: make redis port configurable * root: parse redis port from config as an integer * code formatting * lifecycle: truncate line under 100 chars * lifecycle: incorrect indenting on newline --- authentik/lib/default.yml | 1 + authentik/root/settings.py | 12 ++++++------ lifecycle/wait_for_db.py | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/authentik/lib/default.yml b/authentik/lib/default.yml index fe5056e7f..53091b011 100644 --- a/authentik/lib/default.yml +++ b/authentik/lib/default.yml @@ -13,6 +13,7 @@ web: redis: host: localhost + port: 6379 password: '' cache_db: 0 message_queue_db: 1 diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 3b12469a0..1354e187a 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -192,8 +192,8 @@ CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": ( - f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:6379" - f"/{CONFIG.y('redis.cache_db')}" + f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:" + f"{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.cache_db')}" ), "TIMEOUT": int(CONFIG.y("redis.cache_timeout", 300)), "OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"}, @@ -252,8 +252,8 @@ CHANNEL_LAYERS = { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { "hosts": [ - f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:6379" - f"/{CONFIG.y('redis.ws_db')}" + f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:" + f"{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.ws_db')}" ], }, }, @@ -332,11 +332,11 @@ CELERY_TASK_CREATE_MISSING_QUEUES = True CELERY_TASK_DEFAULT_QUEUE = "authentik" CELERY_BROKER_URL = ( f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}" - f":6379/{CONFIG.y('redis.message_queue_db')}" + f":{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.message_queue_db')}" ) CELERY_RESULT_BACKEND = ( f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}" - f":6379/{CONFIG.y('redis.message_queue_db')}" + f":{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.message_queue_db')}" ) # Database backup diff --git a/lifecycle/wait_for_db.py b/lifecycle/wait_for_db.py index 9e2bc8e53..fe78f8fd9 100755 --- a/lifecycle/wait_for_db.py +++ b/lifecycle/wait_for_db.py @@ -43,8 +43,8 @@ while True: while True: try: redis = Redis.from_url( - f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:6379" - f"/{CONFIG.y('redis.ws_db')}" + f"redis://:{CONFIG.y('redis.password')}@{CONFIG.y('redis.host')}:" + f"{int(CONFIG.y('redis.port'))}/{CONFIG.y('redis.ws_db')}" ) redis.ping() break