root: allow custom settings via python module
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
f5c89f68a4
commit
3418943949
|
@ -194,11 +194,9 @@ pip-selfcheck.json
|
||||||
/static/
|
/static/
|
||||||
local.env.yml
|
local.env.yml
|
||||||
|
|
||||||
# Selenium Screenshots
|
|
||||||
selenium_screenshots/
|
|
||||||
backups/
|
|
||||||
media/
|
media/
|
||||||
*mmdb
|
*mmdb
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
/gen-*/
|
/gen-*/
|
||||||
|
data/
|
||||||
|
|
|
@ -452,23 +452,30 @@ _DISALLOWED_ITEMS = [
|
||||||
"AUTHENTICATION_BACKENDS",
|
"AUTHENTICATION_BACKENDS",
|
||||||
"CELERY_BEAT_SCHEDULE",
|
"CELERY_BEAT_SCHEDULE",
|
||||||
]
|
]
|
||||||
# Load subapps's INSTALLED_APPS
|
|
||||||
for _app in INSTALLED_APPS:
|
|
||||||
if _app.startswith("authentik"):
|
def _update_settings(app_path: str):
|
||||||
if "apps" in _app:
|
|
||||||
_app = ".".join(_app.split(".")[:-2])
|
|
||||||
try:
|
try:
|
||||||
app_settings = importlib.import_module(f"{_app}.settings")
|
settings_module = importlib.import_module(app_path)
|
||||||
INSTALLED_APPS.extend(getattr(app_settings, "INSTALLED_APPS", []))
|
CONFIG.log("debug", "Loaded app settings", path=app_path)
|
||||||
MIDDLEWARE.extend(getattr(app_settings, "MIDDLEWARE", []))
|
INSTALLED_APPS.extend(getattr(settings_module, "INSTALLED_APPS", []))
|
||||||
AUTHENTICATION_BACKENDS.extend(getattr(app_settings, "AUTHENTICATION_BACKENDS", []))
|
MIDDLEWARE.extend(getattr(settings_module, "MIDDLEWARE", []))
|
||||||
CELERY_BEAT_SCHEDULE.update(getattr(app_settings, "CELERY_BEAT_SCHEDULE", {}))
|
AUTHENTICATION_BACKENDS.extend(getattr(settings_module, "AUTHENTICATION_BACKENDS", []))
|
||||||
for _attr in dir(app_settings):
|
CELERY_BEAT_SCHEDULE.update(getattr(settings_module, "CELERY_BEAT_SCHEDULE", {}))
|
||||||
|
for _attr in dir(settings_module):
|
||||||
if not _attr.startswith("__") and _attr not in _DISALLOWED_ITEMS:
|
if not _attr.startswith("__") and _attr not in _DISALLOWED_ITEMS:
|
||||||
globals()[_attr] = getattr(app_settings, _attr)
|
globals()[_attr] = getattr(settings_module, _attr)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Load subapps's settings
|
||||||
|
for _app in INSTALLED_APPS:
|
||||||
|
if not _app.startswith("authentik"):
|
||||||
|
continue
|
||||||
|
_update_settings(f"{_app}.settings")
|
||||||
|
_update_settings("data.user_settings")
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
CELERY_TASK_ALWAYS_EAGER = True
|
CELERY_TASK_ALWAYS_EAGER = True
|
||||||
os.environ[ENV_GIT_HASH_KEY] = "dev"
|
os.environ[ENV_GIT_HASH_KEY] = "dev"
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache, wraps
|
from functools import lru_cache, wraps
|
||||||
from os import environ, makedirs
|
from os import environ
|
||||||
from time import sleep, time
|
from time import sleep
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||||
|
@ -111,11 +111,6 @@ class SeleniumTestCase(StaticLiveServerTestCase):
|
||||||
raise ValueError(f"Webdriver failed after {RETRIES}.")
|
raise ValueError(f"Webdriver failed after {RETRIES}.")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if "TF_BUILD" in environ:
|
|
||||||
makedirs("selenium_screenshots/", exist_ok=True)
|
|
||||||
screenshot_file = f"selenium_screenshots/{self.__class__.__name__}_{time()}.png"
|
|
||||||
self.driver.save_screenshot(screenshot_file)
|
|
||||||
self.logger.warning("Saved screenshot", file=screenshot_file)
|
|
||||||
self.logger.debug("--------browser logs")
|
self.logger.debug("--------browser logs")
|
||||||
for line in self.driver.get_log("browser"):
|
for line in self.driver.get_log("browser"):
|
||||||
self.logger.debug(line["message"], source=line["source"], level=line["level"])
|
self.logger.debug(line["message"], source=line["source"], level=line["level"])
|
||||||
|
|
|
@ -278,3 +278,11 @@ Requires authentik 2022.9
|
||||||
Configure how many gunicorn threads a worker processes should have (see https://docs.gunicorn.org/en/stable/design.html).
|
Configure how many gunicorn threads a worker processes should have (see https://docs.gunicorn.org/en/stable/design.html).
|
||||||
|
|
||||||
Defaults to 4.
|
Defaults to 4.
|
||||||
|
|
||||||
|
## Custom python settings
|
||||||
|
|
||||||
|
To modify additional settings further than the options above allow, you can create a custom python file and mount it to `/data/user_settings.py`. This file will be loaded on startup by both the server and the worker. All default settings are [here](https://github.com/goauthentik/authentik/blob/main/authentik/root/settings.py)
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
Using these custom settings is not supported and can prevent your authentik instance from starting. Use with caution.
|
||||||
|
:::
|
||||||
|
|
Reference in New Issue