From 95db1ecf622e9871a41b9b355d337d6e00980ad5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 10 May 2025 17:14:11 +0200 Subject: [PATCH] move config...? Signed-off-by: Jens Langhammer --- authentik/admin/api/system.py | 2 +- authentik/admin/tasks.py | 2 +- authentik/admin/tests/test_tasks.py | 2 +- authentik/api/v3/config.py | 2 +- authentik/blueprints/migrations/0001_initial.py | 2 +- authentik/blueprints/models.py | 2 +- authentik/blueprints/tests/test_v1_api.py | 2 +- authentik/blueprints/tests/test_v1_tasks.py | 2 +- authentik/blueprints/v1/tasks.py | 2 +- authentik/brands/models.py | 2 +- authentik/{lib/config.py => common/config/__init__.py} | 6 +++--- authentik/{lib => common/config}/config.go | 2 +- authentik/{lib => common/config}/default.yml | 6 +++--- .../{lib/tests/test_config.py => common/config/tests.py} | 4 ++-- authentik/core/management/commands/worker.py | 2 +- authentik/core/views/interface.py | 2 +- authentik/crypto/tasks.py | 2 +- authentik/crypto/tests.py | 2 +- authentik/events/apps.py | 2 +- authentik/events/context_processors/asn.py | 2 +- authentik/events/context_processors/geoip.py | 2 +- authentik/flows/models.py | 2 +- authentik/flows/planner.py | 2 +- authentik/lib/utils/http.py | 2 +- authentik/lib/utils/reflection.py | 2 +- authentik/outposts/apps.py | 2 +- authentik/outposts/controllers/base.py | 2 +- authentik/outposts/models.py | 2 +- authentik/outposts/tasks.py | 2 +- authentik/policies/process.py | 2 +- authentik/policies/reputation/models.py | 2 +- authentik/providers/oauth2/views/device_backchannel.py | 2 +- authentik/root/db/base.py | 2 +- authentik/root/debug.py | 2 +- authentik/root/install_id.py | 2 +- authentik/root/logging.py | 2 +- authentik/root/sentry.py | 2 +- authentik/root/settings.py | 2 +- authentik/root/storages.py | 2 +- authentik/root/test_runner.py | 2 +- authentik/root/urls.py | 2 +- authentik/root/websocket.py | 2 +- authentik/sources/kerberos/tasks.py | 2 +- authentik/sources/ldap/models.py | 2 +- authentik/sources/ldap/sync/base.py | 2 +- authentik/sources/ldap/tasks.py | 2 +- authentik/stages/authenticator_email/models.py | 2 +- authentik/stages/authenticator_email/tests.py | 2 +- authentik/stages/email/models.py | 2 +- authentik/stages/email/tests/test_stage.py | 2 +- authentik/tenants/api/tenants.py | 2 +- authentik/tenants/checks.py | 2 +- authentik/tenants/migrations/0001_initial.py | 2 +- .../0002_tenant_default_token_duration_and_more.py | 2 +- authentik/tenants/tests/test_api.py | 2 +- authentik/tenants/tests/test_domain.py | 2 +- authentik/tenants/tests/test_recovery.py | 2 +- authentik/tenants/urls.py | 2 +- authentik/tenants/utils.py | 2 +- internal/config/config.go | 6 +++--- lifecycle/gunicorn.conf.py | 2 +- lifecycle/migrate.py | 2 +- lifecycle/system_migrations/install_id.py | 2 +- lifecycle/system_migrations/tenant_files.py | 2 +- lifecycle/system_migrations/to_0_13_authentik.py | 2 +- lifecycle/wait_for_db.py | 2 +- manage.py | 2 +- tests/e2e/test_flows_enroll.py | 2 +- tests/e2e/test_flows_recovery.py | 2 +- tests/integration/test_outpost_kubernetes.py | 2 +- 70 files changed, 77 insertions(+), 77 deletions(-) rename authentik/{lib/config.py => common/config/__init__.py} (98%) rename authentik/{lib => common/config}/config.go (89%) rename authentik/{lib => common/config}/default.yml (94%) rename authentik/{lib/tests/test_config.py => common/config/tests.py} (99%) diff --git a/authentik/admin/api/system.py b/authentik/admin/api/system.py index f8f8805a48..f572c248d4 100644 --- a/authentik/admin/api/system.py +++ b/authentik/admin/api/system.py @@ -18,9 +18,9 @@ from rest_framework.response import Response from rest_framework.views import APIView from authentik import get_full_version +from authentik.common.config import CONFIG from authentik.core.api.utils import PassiveSerializer from authentik.enterprise.license import LicenseKey -from authentik.lib.config import CONFIG from authentik.lib.utils.reflection import get_env from authentik.rbac.permissions import HasPermission diff --git a/authentik/admin/tasks.py b/authentik/admin/tasks.py index 8d38adb2cc..a0c671a97f 100644 --- a/authentik/admin/tasks.py +++ b/authentik/admin/tasks.py @@ -9,9 +9,9 @@ from structlog.stdlib import get_logger from authentik import __version__, get_build_hash from authentik.admin.apps import PROM_INFO +from authentik.common.config import CONFIG from authentik.events.models import Event, EventAction, Notification from authentik.events.system_tasks import SystemTask, TaskStatus, prefill_task -from authentik.lib.config import CONFIG from authentik.lib.utils.http import get_http_session from authentik.root.celery import CELERY_APP diff --git a/authentik/admin/tests/test_tasks.py b/authentik/admin/tests/test_tasks.py index b88d16aec9..d1cd35d1d8 100644 --- a/authentik/admin/tests/test_tasks.py +++ b/authentik/admin/tests/test_tasks.py @@ -9,8 +9,8 @@ from authentik.admin.tasks import ( clear_update_notifications, update_latest_version, ) +from authentik.common.config import CONFIG from authentik.events.models import Event, EventAction -from authentik.lib.config import CONFIG RESPONSE_VALID = { "$schema": "https://version.goauthentik.io/schema.json", diff --git a/authentik/api/v3/config.py b/authentik/api/v3/config.py index 151796afc4..6c8e5858d6 100644 --- a/authentik/api/v3/config.py +++ b/authentik/api/v3/config.py @@ -19,9 +19,9 @@ from rest_framework.request import Request from rest_framework.response import Response from rest_framework.views import APIView +from authentik.common.config import CONFIG from authentik.core.api.utils import PassiveSerializer from authentik.events.context_processors.base import get_context_processors -from authentik.lib.config import CONFIG capabilities = Signal() diff --git a/authentik/blueprints/migrations/0001_initial.py b/authentik/blueprints/migrations/0001_initial.py index 0d1bfd7ac8..ae266a287d 100644 --- a/authentik/blueprints/migrations/0001_initial.py +++ b/authentik/blueprints/migrations/0001_initial.py @@ -11,7 +11,7 @@ from django.db.backends.base.schema import BaseDatabaseSchemaEditor from yaml import load from authentik.blueprints.v1.labels import LABEL_AUTHENTIK_SYSTEM -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG def check_blueprint_v1_file(BlueprintInstance: type, db_alias, path: Path): diff --git a/authentik/blueprints/models.py b/authentik/blueprints/models.py index 8cc1cffbe3..f0d2896d0a 100644 --- a/authentik/blueprints/models.py +++ b/authentik/blueprints/models.py @@ -10,8 +10,8 @@ from rest_framework.serializers import Serializer from structlog import get_logger from authentik.blueprints.v1.oci import OCI_PREFIX, BlueprintOCIClient, OCIException +from authentik.common.config import CONFIG from authentik.common.exceptions import NotReportedException -from authentik.lib.config import CONFIG from authentik.lib.models import CreatedUpdatedModel, SerializerModel LOGGER = get_logger() diff --git a/authentik/blueprints/tests/test_v1_api.py b/authentik/blueprints/tests/test_v1_api.py index f4e6d0fb0c..b615f5ddf4 100644 --- a/authentik/blueprints/tests/test_v1_api.py +++ b/authentik/blueprints/tests/test_v1_api.py @@ -7,8 +7,8 @@ from django.urls import reverse from rest_framework.test import APITestCase from yaml import dump +from authentik.common.config import CONFIG from authentik.core.tests.utils import create_test_admin_user -from authentik.lib.config import CONFIG TMP = mkdtemp("authentik-blueprints") diff --git a/authentik/blueprints/tests/test_v1_tasks.py b/authentik/blueprints/tests/test_v1_tasks.py index 9a12be37fb..4afdf58e37 100644 --- a/authentik/blueprints/tests/test_v1_tasks.py +++ b/authentik/blueprints/tests/test_v1_tasks.py @@ -8,8 +8,8 @@ from yaml import dump from authentik.blueprints.models import BlueprintInstance, BlueprintInstanceStatus from authentik.blueprints.v1.tasks import apply_blueprint, blueprints_discovery, blueprints_find +from authentik.common.config import CONFIG from authentik.crypto.generators import generate_id -from authentik.lib.config import CONFIG TMP = mkdtemp("authentik-blueprints") diff --git a/authentik/blueprints/v1/tasks.py b/authentik/blueprints/v1/tasks.py index 73e712b8f8..471c9ba26b 100644 --- a/authentik/blueprints/v1/tasks.py +++ b/authentik/blueprints/v1/tasks.py @@ -30,11 +30,11 @@ from authentik.blueprints.v1.common import BlueprintLoader, BlueprintMetadata, E from authentik.blueprints.v1.importer import Importer from authentik.blueprints.v1.labels import LABEL_AUTHENTIK_INSTANTIATE from authentik.blueprints.v1.oci import OCI_PREFIX +from authentik.common.config import CONFIG from authentik.events.logs import capture_logs from authentik.events.models import TaskStatus from authentik.events.system_tasks import SystemTask, prefill_task from authentik.events.utils import sanitize_dict -from authentik.lib.config import CONFIG from authentik.root.celery import CELERY_APP from authentik.tenants.models import Tenant diff --git a/authentik/brands/models.py b/authentik/brands/models.py index cc8cc43787..ee68ad5900 100644 --- a/authentik/brands/models.py +++ b/authentik/brands/models.py @@ -8,9 +8,9 @@ from django.utils.translation import gettext_lazy as _ from rest_framework.serializers import Serializer from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.crypto.models import CertificateKeyPair from authentik.flows.models import Flow -from authentik.lib.config import CONFIG from authentik.lib.models import SerializerModel LOGGER = get_logger() diff --git a/authentik/lib/config.py b/authentik/common/config/__init__.py similarity index 98% rename from authentik/lib/config.py rename to authentik/common/config/__init__.py index dc940b108d..0cdd04fc81 100644 --- a/authentik/lib/config.py +++ b/authentik/common/config/__init__.py @@ -18,11 +18,11 @@ from typing import Any from urllib.parse import quote_plus, urlparse import yaml -from django.conf import ImproperlyConfigured +from django.core.exceptions import ImproperlyConfigured from authentik.lib.utils.dict import get_path_from_dict, set_path_in_dict -SEARCH_PATHS = ["authentik/lib/default.yml", "/etc/authentik/config.yml", ""] + glob( +SEARCH_PATHS = ["authentik/common/config/default.yml", "/etc/authentik/config.yml", ""] + glob( "/etc/authentik/config.d/*.yml", recursive=True ) ENV_PREFIX = "AUTHENTIK" @@ -100,7 +100,7 @@ class ConfigLoader: def __init__(self, **kwargs): super().__init__() self.__config = {} - base_dir = Path(__file__).parent.joinpath(Path("../..")).resolve() + base_dir = Path(__file__).parent.joinpath(Path("../../..")).resolve() for _path in SEARCH_PATHS: path = Path(_path) # Check if path is relative, and if so join with base_dir diff --git a/authentik/lib/config.go b/authentik/common/config/config.go similarity index 89% rename from authentik/lib/config.go rename to authentik/common/config/config.go index f595f2423e..f6db2c496a 100644 --- a/authentik/lib/config.go +++ b/authentik/common/config/config.go @@ -1,4 +1,4 @@ -package lib +package config import _ "embed" diff --git a/authentik/lib/default.yml b/authentik/common/config/default.yml similarity index 94% rename from authentik/lib/default.yml rename to authentik/common/config/default.yml index d6f3579055..bb0b77ed56 100644 --- a/authentik/lib/default.yml +++ b/authentik/common/config/default.yml @@ -8,12 +8,12 @@ # make gen-dev-config # ``` # -# You may edit the generated file to override the configuration below. +# You may edit the generated file to override the configuration below. # -# When making modifying the default configuration file, +# When making modifying the default configuration file, # ensure that the corresponding documentation is updated to match. # -# @see {@link ../../website/docs/install-config/configuration/configuration.mdx Configuration documentation} for more information. +# @see {@link ../../../website/docs/install-config/configuration/configuration.mdx Configuration documentation} for more information. postgresql: host: localhost diff --git a/authentik/lib/tests/test_config.py b/authentik/common/config/tests.py similarity index 99% rename from authentik/lib/tests/test_config.py rename to authentik/common/config/tests.py index 92a03534c7..53e434c5ed 100644 --- a/authentik/lib/tests/test_config.py +++ b/authentik/common/config/tests.py @@ -6,10 +6,10 @@ from os import chmod, environ, unlink, write from tempfile import mkstemp from unittest import mock -from django.conf import ImproperlyConfigured +from django.core.exceptions import ImproperlyConfigured from django.test import TestCase -from authentik.lib.config import ( +from authentik.common.config import ( ENV_PREFIX, UNSET, Attr, diff --git a/authentik/core/management/commands/worker.py b/authentik/core/management/commands/worker.py index 54d87fa3fe..5bc0df2457 100644 --- a/authentik/core/management/commands/worker.py +++ b/authentik/core/management/commands/worker.py @@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand from django.db import close_old_connections from structlog.stdlib import get_logger -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from authentik.root.celery import CELERY_APP from authentik.root.debug import start_debug_server diff --git a/authentik/core/views/interface.py b/authentik/core/views/interface.py index a90ba5fc55..2c2c966735 100644 --- a/authentik/core/views/interface.py +++ b/authentik/core/views/interface.py @@ -15,8 +15,8 @@ from authentik.admin.tasks import LOCAL_VERSION from authentik.api.v3.config import ConfigView from authentik.brands.api import CurrentBrandSerializer from authentik.brands.models import Brand +from authentik.common.config import CONFIG from authentik.core.models import UserTypes -from authentik.lib.config import CONFIG from authentik.policies.denied import AccessDeniedResponse diff --git a/authentik/crypto/tasks.py b/authentik/crypto/tasks.py index bce3f998c7..7f999670f9 100644 --- a/authentik/crypto/tasks.py +++ b/authentik/crypto/tasks.py @@ -9,10 +9,10 @@ from cryptography.x509.base import load_pem_x509_certificate from django.utils.translation import gettext_lazy as _ from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.crypto.models import CertificateKeyPair from authentik.events.models import TaskStatus from authentik.events.system_tasks import SystemTask, prefill_task -from authentik.lib.config import CONFIG from authentik.root.celery import CELERY_APP LOGGER = get_logger() diff --git a/authentik/crypto/tests.py b/authentik/crypto/tests.py index 2cb8b952b9..f73c594dbd 100644 --- a/authentik/crypto/tests.py +++ b/authentik/crypto/tests.py @@ -10,6 +10,7 @@ from django.urls import reverse from django.utils.timezone import now from rest_framework.test import APITestCase +from authentik.common.config import CONFIG from authentik.core.api.used_by import DeleteAction from authentik.core.tests.utils import create_test_admin_user, create_test_cert, create_test_flow from authentik.crypto.api import CertificateKeyPairSerializer @@ -17,7 +18,6 @@ from authentik.crypto.builder import CertificateBuilder from authentik.crypto.generators import generate_id, generate_key from authentik.crypto.models import CertificateKeyPair from authentik.crypto.tasks import MANAGED_DISCOVERED, certificate_discovery -from authentik.lib.config import CONFIG from authentik.providers.oauth2.models import OAuth2Provider, RedirectURI, RedirectURIMatchingMode diff --git a/authentik/events/apps.py b/authentik/events/apps.py index 915b923afc..3a16b9d151 100644 --- a/authentik/events/apps.py +++ b/authentik/events/apps.py @@ -4,7 +4,7 @@ from celery.schedules import crontab from prometheus_client import Gauge, Histogram from authentik.blueprints.apps import ManagedAppConfig -from authentik.lib.config import CONFIG, ENV_PREFIX +from authentik.common.config import CONFIG, ENV_PREFIX from authentik.lib.utils.reflection import path_to_class from authentik.root.celery import CELERY_APP diff --git a/authentik/events/context_processors/asn.py b/authentik/events/context_processors/asn.py index 6de0b9cbf6..5ecb35180f 100644 --- a/authentik/events/context_processors/asn.py +++ b/authentik/events/context_processors/asn.py @@ -7,8 +7,8 @@ from geoip2.errors import GeoIP2Error from geoip2.models import ASN from sentry_sdk import start_span +from authentik.common.config import CONFIG from authentik.events.context_processors.mmdb import MMDBContextProcessor -from authentik.lib.config import CONFIG from authentik.root.middleware import ClientIPMiddleware if TYPE_CHECKING: diff --git a/authentik/events/context_processors/geoip.py b/authentik/events/context_processors/geoip.py index cfa8cb400d..969e475b01 100644 --- a/authentik/events/context_processors/geoip.py +++ b/authentik/events/context_processors/geoip.py @@ -7,8 +7,8 @@ from geoip2.errors import GeoIP2Error from geoip2.models import City from sentry_sdk import start_span +from authentik.common.config import CONFIG from authentik.events.context_processors.mmdb import MMDBContextProcessor -from authentik.lib.config import CONFIG from authentik.root.middleware import ClientIPMiddleware if TYPE_CHECKING: diff --git a/authentik/flows/models.py b/authentik/flows/models.py index fda36a25ec..11d62e8165 100644 --- a/authentik/flows/models.py +++ b/authentik/flows/models.py @@ -12,10 +12,10 @@ from model_utils.managers import InheritanceManager from rest_framework.serializers import BaseSerializer from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.core.models import Token from authentik.core.types import UserSettingSerializer from authentik.flows.challenge import FlowLayout -from authentik.lib.config import CONFIG from authentik.lib.models import ( InheritanceForeignKey, SerializerModel, diff --git a/authentik/flows/planner.py b/authentik/flows/planner.py index eb5d9ccae1..1d2458757d 100644 --- a/authentik/flows/planner.py +++ b/authentik/flows/planner.py @@ -9,6 +9,7 @@ from sentry_sdk import start_span from sentry_sdk.tracing import Span from structlog.stdlib import BoundLogger, get_logger +from authentik.common.config import CONFIG from authentik.core.models import User from authentik.events.models import cleanse_dict from authentik.flows.apps import HIST_FLOWS_PLAN_TIME @@ -22,7 +23,6 @@ from authentik.flows.models import ( Stage, in_memory_stage, ) -from authentik.lib.config import CONFIG from authentik.lib.utils.urls import redirect_with_qs from authentik.outposts.models import Outpost from authentik.policies.engine import PolicyEngine diff --git a/authentik/lib/utils/http.py b/authentik/lib/utils/http.py index 81ff775423..e8ec618ec3 100644 --- a/authentik/lib/utils/http.py +++ b/authentik/lib/utils/http.py @@ -6,7 +6,7 @@ from requests.sessions import PreparedRequest, Session from structlog.stdlib import get_logger from authentik import get_full_version -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG LOGGER = get_logger() diff --git a/authentik/lib/utils/reflection.py b/authentik/lib/utils/reflection.py index b8f8e4c08e..00c61f8ddd 100644 --- a/authentik/lib/utils/reflection.py +++ b/authentik/lib/utils/reflection.py @@ -7,7 +7,7 @@ from tempfile import gettempdir from django.conf import settings -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG SERVICE_HOST_ENV_NAME = "KUBERNETES_SERVICE_HOST" diff --git a/authentik/outposts/apps.py b/authentik/outposts/apps.py index a7680a9aa5..01a6b49fd1 100644 --- a/authentik/outposts/apps.py +++ b/authentik/outposts/apps.py @@ -4,7 +4,7 @@ from prometheus_client import Gauge from structlog.stdlib import get_logger from authentik.blueprints.apps import ManagedAppConfig -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG LOGGER = get_logger() diff --git a/authentik/outposts/controllers/base.py b/authentik/outposts/controllers/base.py index 50d2c859f9..e8ae12645d 100644 --- a/authentik/outposts/controllers/base.py +++ b/authentik/outposts/controllers/base.py @@ -5,9 +5,9 @@ from dataclasses import dataclass from structlog.stdlib import get_logger from authentik import __version__, get_build_hash +from authentik.common.config import CONFIG from authentik.common.exceptions import NotReportedException from authentik.events.logs import LogEvent, capture_logs -from authentik.lib.config import CONFIG from authentik.outposts.models import ( Outpost, OutpostServiceConnection, diff --git a/authentik/outposts/models.py b/authentik/outposts/models.py index d8fa27311e..5621cbde4b 100644 --- a/authentik/outposts/models.py +++ b/authentik/outposts/models.py @@ -22,6 +22,7 @@ from structlog.stdlib import get_logger from authentik import __version__, get_build_hash from authentik.blueprints.models import ManagedModel from authentik.brands.models import Brand +from authentik.common.config import CONFIG from authentik.common.exceptions import NotReportedException from authentik.core.models import ( USER_PATH_SYSTEM_PREFIX, @@ -33,7 +34,6 @@ from authentik.core.models import ( ) from authentik.crypto.models import CertificateKeyPair from authentik.events.models import Event, EventAction -from authentik.lib.config import CONFIG from authentik.lib.models import ( InheritanceForeignKey, SerializerModel, diff --git a/authentik/outposts/tasks.py b/authentik/outposts/tasks.py index e09dcf769f..f11237bd64 100644 --- a/authentik/outposts/tasks.py +++ b/authentik/outposts/tasks.py @@ -18,9 +18,9 @@ from kubernetes.config.kube_config import KUBE_CONFIG_DEFAULT_LOCATION from structlog.stdlib import get_logger from yaml import safe_load +from authentik.common.config import CONFIG from authentik.events.models import TaskStatus from authentik.events.system_tasks import SystemTask, prefill_task -from authentik.lib.config import CONFIG from authentik.lib.utils.reflection import path_to_class from authentik.outposts.consumer import OUTPOST_GROUP from authentik.outposts.controllers.base import BaseController, ControllerException diff --git a/authentik/policies/process.py b/authentik/policies/process.py index 624edf047d..8d3ffbd755 100644 --- a/authentik/policies/process.py +++ b/authentik/policies/process.py @@ -8,8 +8,8 @@ from sentry_sdk import start_span from sentry_sdk.tracing import Span from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.events.models import Event, EventAction -from authentik.lib.config import CONFIG from authentik.lib.utils.errors import exception_to_string from authentik.lib.utils.reflection import class_to_path from authentik.policies.apps import HIST_POLICIES_EXECUTION_TIME diff --git a/authentik/policies/reputation/models.py b/authentik/policies/reputation/models.py index 6ddc0ad9cf..7a9a10f316 100644 --- a/authentik/policies/reputation/models.py +++ b/authentik/policies/reputation/models.py @@ -11,8 +11,8 @@ from django.utils.translation import gettext as _ from rest_framework.serializers import BaseSerializer from structlog import get_logger +from authentik.common.config import CONFIG from authentik.core.models import ExpiringModel -from authentik.lib.config import CONFIG from authentik.lib.models import SerializerModel, internal_model from authentik.policies.models import Policy from authentik.policies.types import PolicyRequest, PolicyResult diff --git a/authentik/providers/oauth2/views/device_backchannel.py b/authentik/providers/oauth2/views/device_backchannel.py index 1ec73808b5..d66d5fca1f 100644 --- a/authentik/providers/oauth2/views/device_backchannel.py +++ b/authentik/providers/oauth2/views/device_backchannel.py @@ -11,8 +11,8 @@ from django.views.decorators.csrf import csrf_exempt from rest_framework.throttling import AnonRateThrottle from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.core.models import Application -from authentik.lib.config import CONFIG from authentik.lib.utils.time import timedelta_from_string from authentik.providers.oauth2.models import DeviceToken, OAuth2Provider from authentik.providers.oauth2.views.device_init import QS_KEY_CODE diff --git a/authentik/root/db/base.py b/authentik/root/db/base.py index 2385e1b972..4e45a7163d 100644 --- a/authentik/root/db/base.py +++ b/authentik/root/db/base.py @@ -2,7 +2,7 @@ from django_tenants.postgresql_backend.base import DatabaseWrapper as BaseDatabaseWrapper -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG class DatabaseWrapper(BaseDatabaseWrapper): diff --git a/authentik/root/debug.py b/authentik/root/debug.py index 76d7422b6a..aea974284f 100644 --- a/authentik/root/debug.py +++ b/authentik/root/debug.py @@ -1,6 +1,6 @@ from structlog.stdlib import get_logger -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG LOGGER = get_logger() diff --git a/authentik/root/install_id.py b/authentik/root/install_id.py index ec03da61d4..8ca948d941 100644 --- a/authentik/root/install_id.py +++ b/authentik/root/install_id.py @@ -5,7 +5,7 @@ from uuid import uuid4 from psycopg import connect -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG # We need to string format the query as tables and schemas can't be set by parameters # not a security issue as the config value is set by the person installing authentik diff --git a/authentik/root/logging.py b/authentik/root/logging.py index 0ffb74530e..8720cf8301 100644 --- a/authentik/root/logging.py +++ b/authentik/root/logging.py @@ -7,7 +7,7 @@ from os import getpid import structlog from django.db import connection -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG LOG_PRE_CHAIN = [ # Add the log level and a timestamp to the event_dict if the log entry diff --git a/authentik/root/sentry.py b/authentik/root/sentry.py index 1d768f8ddf..be9cf29be7 100644 --- a/authentik/root/sentry.py +++ b/authentik/root/sentry.py @@ -32,8 +32,8 @@ from structlog.stdlib import get_logger from websockets.exceptions import WebSocketException from authentik import __version__, get_build_hash +from authentik.common.config import CONFIG from authentik.common.exceptions import NotReportedException -from authentik.lib.config import CONFIG from authentik.lib.utils.http import authentik_user_agent from authentik.lib.utils.reflection import get_env diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 959fe49753..0fc345da37 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -11,7 +11,7 @@ from sentry_sdk import set_tag from xmlsec import enable_debug_trace from authentik import __version__ -from authentik.lib.config import CONFIG, django_db_config, redis_url +from authentik.common.config import CONFIG, django_db_config, redis_url from authentik.lib.utils.reflection import get_env from authentik.lib.utils.time import timedelta_from_string from authentik.root.logging import get_logger_config, structlog_configure diff --git a/authentik/root/storages.py b/authentik/root/storages.py index e76efb3374..1c355a3d45 100644 --- a/authentik/root/storages.py +++ b/authentik/root/storages.py @@ -10,7 +10,7 @@ from django.db import connection from storages.backends.s3 import S3Storage as BaseS3Storage from storages.utils import clean_name, safe_join -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG class FileStorage(FileSystemStorage): diff --git a/authentik/root/test_runner.py b/authentik/root/test_runner.py index 768a44a618..bb01a32773 100644 --- a/authentik/root/test_runner.py +++ b/authentik/root/test_runner.py @@ -8,7 +8,7 @@ import pytest from django.conf import settings from django.test.runner import DiscoverRunner -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from authentik.root.sentry import sentry_init from authentik.root.signals import post_startup, pre_startup, startup from tests.e2e.utils import get_docker_tag diff --git a/authentik/root/urls.py b/authentik/root/urls.py index b12eb83168..679713fa7e 100644 --- a/authentik/root/urls.py +++ b/authentik/root/urls.py @@ -3,8 +3,8 @@ from django.urls import include, path from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.core.views import error -from authentik.lib.config import CONFIG from authentik.lib.utils.reflection import get_apps from authentik.root.monitoring import LiveView, MetricsView, ReadyView diff --git a/authentik/root/websocket.py b/authentik/root/websocket.py index 70fec2055f..8e3e36b76f 100644 --- a/authentik/root/websocket.py +++ b/authentik/root/websocket.py @@ -6,7 +6,7 @@ from channels.routing import URLRouter from django.urls import path from structlog.stdlib import get_logger -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from authentik.lib.utils.reflection import get_apps LOGGER = get_logger() diff --git a/authentik/sources/kerberos/tasks.py b/authentik/sources/kerberos/tasks.py index 189114a094..04ff235a9b 100644 --- a/authentik/sources/kerberos/tasks.py +++ b/authentik/sources/kerberos/tasks.py @@ -3,11 +3,11 @@ from django.core.cache import cache from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.common.sync.outgoing.exceptions import StopSync from authentik.events.models import SystemTask as DBSystemTask from authentik.events.models import TaskStatus from authentik.events.system_tasks import SystemTask -from authentik.lib.config import CONFIG from authentik.lib.utils.errors import exception_to_string from authentik.root.celery import CELERY_APP from authentik.sources.kerberos.models import KerberosSource diff --git a/authentik/sources/ldap/models.py b/authentik/sources/ldap/models.py index d34ec70c41..8fc846fb69 100644 --- a/authentik/sources/ldap/models.py +++ b/authentik/sources/ldap/models.py @@ -15,6 +15,7 @@ from ldap3 import ALL, NONE, RANDOM, Connection, Server, ServerPool, Tls from ldap3.core.exceptions import LDAPException, LDAPInsufficientAccessRightsResult, LDAPSchemaError from rest_framework.serializers import Serializer +from authentik.common.config import CONFIG from authentik.common.ldap.constants import LDAP_DISTINGUISHED_NAME from authentik.core.models import ( Group, @@ -24,7 +25,6 @@ from authentik.core.models import ( UserSourceConnection, ) from authentik.crypto.models import CertificateKeyPair -from authentik.lib.config import CONFIG from authentik.lib.models import DomainlessURLValidator, internal_model LDAP_TIMEOUT = 15 diff --git a/authentik/sources/ldap/sync/base.py b/authentik/sources/ldap/sync/base.py index d653fca07b..e1886996ef 100644 --- a/authentik/sources/ldap/sync/base.py +++ b/authentik/sources/ldap/sync/base.py @@ -6,9 +6,9 @@ from django.conf import settings from ldap3 import DEREF_ALWAYS, SUBTREE, Connection from structlog.stdlib import BoundLogger, get_logger +from authentik.common.config import CONFIG from authentik.common.sync.mapper import PropertyMappingManager from authentik.core.sources.mapper import SourceMapper -from authentik.lib.config import CONFIG from authentik.sources.ldap.models import LDAPSource diff --git a/authentik/sources/ldap/tasks.py b/authentik/sources/ldap/tasks.py index 9eafae7aa2..5e4b3a644d 100644 --- a/authentik/sources/ldap/tasks.py +++ b/authentik/sources/ldap/tasks.py @@ -7,11 +7,11 @@ from django.core.cache import cache from ldap3.core.exceptions import LDAPException from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.common.sync.outgoing.exceptions import StopSync from authentik.events.models import SystemTask as DBSystemTask from authentik.events.models import TaskStatus from authentik.events.system_tasks import SystemTask -from authentik.lib.config import CONFIG from authentik.lib.utils.errors import exception_to_string from authentik.lib.utils.reflection import class_to_path, path_to_class from authentik.root.celery import CELERY_APP diff --git a/authentik/stages/authenticator_email/models.py b/authentik/stages/authenticator_email/models.py index 495e1a2512..4536b22366 100644 --- a/authentik/stages/authenticator_email/models.py +++ b/authentik/stages/authenticator_email/models.py @@ -7,11 +7,11 @@ from django.utils.translation import gettext_lazy as _ from django.views import View from rest_framework.serializers import BaseSerializer +from authentik.common.config import CONFIG from authentik.core.types import UserSettingSerializer from authentik.events.models import Event, EventAction from authentik.flows.exceptions import StageInvalidException from authentik.flows.models import ConfigurableStage, FriendlyNamedStage, Stage -from authentik.lib.config import CONFIG from authentik.lib.models import SerializerModel from authentik.lib.utils.errors import exception_to_string from authentik.lib.utils.time import timedelta_string_validator diff --git a/authentik/stages/authenticator_email/tests.py b/authentik/stages/authenticator_email/tests.py index 8a3e9b2884..0ae889a2ff 100644 --- a/authentik/stages/authenticator_email/tests.py +++ b/authentik/stages/authenticator_email/tests.py @@ -10,10 +10,10 @@ from django.template.exceptions import TemplateDoesNotExist from django.urls import reverse from django.utils.timezone import now +from authentik.common.config import CONFIG from authentik.core.tests.utils import create_test_admin_user, create_test_flow, create_test_user from authentik.flows.models import FlowStageBinding from authentik.flows.tests import FlowTestCase -from authentik.lib.config import CONFIG from authentik.lib.utils.email import mask_email from authentik.stages.authenticator_email.api import ( AuthenticatorEmailStageSerializer, diff --git a/authentik/stages/email/models.py b/authentik/stages/email/models.py index ecd47dba4f..886eb4f452 100644 --- a/authentik/stages/email/models.py +++ b/authentik/stages/email/models.py @@ -12,8 +12,8 @@ from django.views import View from rest_framework.serializers import BaseSerializer from structlog.stdlib import get_logger +from authentik.common.config import CONFIG from authentik.flows.models import Stage -from authentik.lib.config import CONFIG from authentik.lib.utils.time import timedelta_string_validator LOGGER = get_logger() diff --git a/authentik/stages/email/tests/test_stage.py b/authentik/stages/email/tests/test_stage.py index b69c87f7c2..55917064b5 100644 --- a/authentik/stages/email/tests/test_stage.py +++ b/authentik/stages/email/tests/test_stage.py @@ -9,6 +9,7 @@ from django.test import RequestFactory from django.urls import reverse from django.utils.http import urlencode +from authentik.common.config import CONFIG from authentik.core.tests.utils import create_test_admin_user, create_test_flow from authentik.crypto.generators import generate_id from authentik.flows.markers import StageMarker @@ -16,7 +17,6 @@ from authentik.flows.models import FlowDesignation, FlowStageBinding, FlowToken from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan from authentik.flows.tests import FlowTestCase from authentik.flows.views.executor import QS_KEY_TOKEN, SESSION_KEY_PLAN, FlowExecutorView -from authentik.lib.config import CONFIG from authentik.stages.email.models import EmailStage from authentik.stages.email.stage import PLAN_CONTEXT_EMAIL_OVERRIDE, EmailStageView diff --git a/authentik/tenants/api/tenants.py b/authentik/tenants/api/tenants.py index f4e97f9a50..c9ca214bf6 100644 --- a/authentik/tenants/api/tenants.py +++ b/authentik/tenants/api/tenants.py @@ -20,9 +20,9 @@ from rest_framework.views import View from rest_framework.viewsets import ModelViewSet from authentik.api.authentication import validate_auth +from authentik.common.config import CONFIG from authentik.core.api.utils import ModelSerializer, PassiveSerializer from authentik.core.models import User -from authentik.lib.config import CONFIG from authentik.recovery.lib import create_admin_group, create_recovery_token from authentik.tenants.models import Tenant diff --git a/authentik/tenants/checks.py b/authentik/tenants/checks.py index 72c7228f51..480f2ca46e 100644 --- a/authentik/tenants/checks.py +++ b/authentik/tenants/checks.py @@ -2,7 +2,7 @@ from django.core.checks import Error, register -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG @register() diff --git a/authentik/tenants/migrations/0001_initial.py b/authentik/tenants/migrations/0001_initial.py index eda3e7c917..9f07922133 100644 --- a/authentik/tenants/migrations/0001_initial.py +++ b/authentik/tenants/migrations/0001_initial.py @@ -8,7 +8,7 @@ from django.db import migrations, models import authentik.lib.utils.time import authentik.tenants.models -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG def create_default_tenant(apps, schema_editor): diff --git a/authentik/tenants/migrations/0002_tenant_default_token_duration_and_more.py b/authentik/tenants/migrations/0002_tenant_default_token_duration_and_more.py index 0aa7accfc8..dbbb84319c 100644 --- a/authentik/tenants/migrations/0002_tenant_default_token_duration_and_more.py +++ b/authentik/tenants/migrations/0002_tenant_default_token_duration_and_more.py @@ -4,7 +4,7 @@ import django.core.validators from django.db import migrations, models import authentik.lib.utils.time -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG class Migration(migrations.Migration): diff --git a/authentik/tenants/tests/test_api.py b/authentik/tenants/tests/test_api.py index a09af2b8f2..17fdd098b8 100644 --- a/authentik/tenants/tests/test_api.py +++ b/authentik/tenants/tests/test_api.py @@ -4,8 +4,8 @@ from json import loads from django.urls import reverse +from authentik.common.config import CONFIG from authentik.crypto.generators import generate_id -from authentik.lib.config import CONFIG from authentik.tenants.tests.utils import TenantAPITestCase TENANTS_API_KEY = generate_id() diff --git a/authentik/tenants/tests/test_domain.py b/authentik/tenants/tests/test_domain.py index 8346eae2ec..b6a91f3850 100644 --- a/authentik/tenants/tests/test_domain.py +++ b/authentik/tenants/tests/test_domain.py @@ -4,8 +4,8 @@ from json import loads from django.urls import reverse +from authentik.common.config import CONFIG from authentik.crypto.generators import generate_id -from authentik.lib.config import CONFIG from authentik.tenants.models import Domain, Tenant from authentik.tenants.tests.utils import TenantAPITestCase diff --git a/authentik/tenants/tests/test_recovery.py b/authentik/tenants/tests/test_recovery.py index be990844f3..c695ddbe74 100644 --- a/authentik/tenants/tests/test_recovery.py +++ b/authentik/tenants/tests/test_recovery.py @@ -5,9 +5,9 @@ from json import loads from django.urls import reverse from django_tenants.utils import get_public_schema_name +from authentik.common.config import CONFIG from authentik.core.models import Token, TokenIntents, User from authentik.crypto.generators import generate_id -from authentik.lib.config import CONFIG from authentik.tenants.models import Tenant from authentik.tenants.tests.utils import TenantAPITestCase diff --git a/authentik/tenants/urls.py b/authentik/tenants/urls.py index b75ed6b43b..d6a1733cb5 100644 --- a/authentik/tenants/urls.py +++ b/authentik/tenants/urls.py @@ -3,7 +3,7 @@ from django.conf import settings from django.urls import path -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from authentik.tenants.api.domains import DomainViewSet from authentik.tenants.api.settings import SettingsView from authentik.tenants.api.tenants import TenantViewSet diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index 7204f39706..50aeaf7c52 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -3,7 +3,7 @@ from django.db import connection from django_tenants.utils import get_public_schema_name -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from authentik.root.install_id import get_install_id from authentik.tenants.models import Tenant diff --git a/internal/config/config.go b/internal/config/config.go index ca1ec09424..f091a8a9b2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,12 +15,12 @@ import ( log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" - "goauthentik.io/authentik/lib" + "goauthentik.io/authentik/common/config" ) var cfg *Config -const defaultConfigPath = "./authentik/lib/default.yml" +const defaultConfigPath = "./authentik/common/config/default.yml" func getConfigPaths() []string { configPaths := []string{defaultConfigPath, "/etc/authentik/config.yml", ""} @@ -70,7 +70,7 @@ func Get() *Config { func (c *Config) Setup(paths ...string) { // initially try to load the default config which is compiled in - err := c.LoadConfig(lib.DefaultConfig()) + err := c.LoadConfig(config.DefaultConfig()) // this should never fail if err != nil { panic(fmt.Errorf("failed to load inbuilt config: %v", err)) diff --git a/lifecycle/gunicorn.conf.py b/lifecycle/gunicorn.conf.py index 13d664d3a7..ed9bb631df 100644 --- a/lifecycle/gunicorn.conf.py +++ b/lifecycle/gunicorn.conf.py @@ -12,7 +12,7 @@ from defusedxml import defuse_stdlib from prometheus_client.values import MultiProcessValue from authentik import get_full_version -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from authentik.lib.utils.http import get_http_session from authentik.lib.utils.reflection import get_env from authentik.root.debug import start_debug_server diff --git a/lifecycle/migrate.py b/lifecycle/migrate.py index f5787a9021..201192d425 100755 --- a/lifecycle/migrate.py +++ b/lifecycle/migrate.py @@ -10,7 +10,7 @@ from typing import Any from psycopg import Connection, Cursor, connect from structlog.stdlib import get_logger -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG LOGGER = get_logger() ADV_LOCK_UID = 1000 diff --git a/lifecycle/system_migrations/install_id.py b/lifecycle/system_migrations/install_id.py index 2f66dcafca..a6ea8363d7 100644 --- a/lifecycle/system_migrations/install_id.py +++ b/lifecycle/system_migrations/install_id.py @@ -1,7 +1,7 @@ # flake8: noqa from uuid import uuid4 -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from lifecycle.migrate import BaseMigration SQL_STATEMENT = """BEGIN TRANSACTION; diff --git a/lifecycle/system_migrations/tenant_files.py b/lifecycle/system_migrations/tenant_files.py index 737e1c0c12..f06f6d6579 100644 --- a/lifecycle/system_migrations/tenant_files.py +++ b/lifecycle/system_migrations/tenant_files.py @@ -1,7 +1,7 @@ # flake8: noqa from pathlib import Path -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from lifecycle.migrate import BaseMigration MEDIA_ROOT = Path(__file__).parent.parent.parent / "media" diff --git a/lifecycle/system_migrations/to_0_13_authentik.py b/lifecycle/system_migrations/to_0_13_authentik.py index c56d3b2d1f..91e168d6ff 100644 --- a/lifecycle/system_migrations/to_0_13_authentik.py +++ b/lifecycle/system_migrations/to_0_13_authentik.py @@ -1,7 +1,7 @@ # flake8: noqa from redis import Redis -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from lifecycle.migrate import BaseMigration SQL_STATEMENT = """BEGIN TRANSACTION; diff --git a/lifecycle/wait_for_db.py b/lifecycle/wait_for_db.py index 2c193c24c4..2f428b8965 100755 --- a/lifecycle/wait_for_db.py +++ b/lifecycle/wait_for_db.py @@ -8,7 +8,7 @@ from psycopg import OperationalError, connect from redis import Redis from redis.exceptions import RedisError -from authentik.lib.config import CONFIG, redis_url +from authentik.common.config import CONFIG, redis_url CHECK_THRESHOLD = 30 diff --git a/manage.py b/manage.py index 09d065e919..395bdd4a41 100755 --- a/manage.py +++ b/manage.py @@ -4,7 +4,7 @@ import os import sys import warnings -from authentik.lib.config import CONFIG +from authentik.common.config import CONFIG from cryptography.hazmat.backends.openssl.backend import backend from defusedxml import defuse_stdlib from django.utils.autoreload import DJANGO_AUTORELOAD_ENV diff --git a/tests/e2e/test_flows_enroll.py b/tests/e2e/test_flows_enroll.py index 1e90495e48..b3aff1ea58 100644 --- a/tests/e2e/test_flows_enroll.py +++ b/tests/e2e/test_flows_enroll.py @@ -7,9 +7,9 @@ from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.wait import WebDriverWait from authentik.blueprints.tests import apply_blueprint +from authentik.common.config import CONFIG from authentik.core.models import User from authentik.flows.models import Flow -from authentik.lib.config import CONFIG from authentik.stages.identification.models import IdentificationStage from tests.e2e.utils import SeleniumTestCase, retry diff --git a/tests/e2e/test_flows_recovery.py b/tests/e2e/test_flows_recovery.py index b70f21e8d9..d14a5d789b 100644 --- a/tests/e2e/test_flows_recovery.py +++ b/tests/e2e/test_flows_recovery.py @@ -7,11 +7,11 @@ from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.wait import WebDriverWait from authentik.blueprints.tests import apply_blueprint +from authentik.common.config import CONFIG from authentik.core.models import User from authentik.core.tests.utils import create_test_admin_user from authentik.crypto.generators import generate_id from authentik.flows.models import Flow -from authentik.lib.config import CONFIG from authentik.stages.identification.models import IdentificationStage from tests.e2e.utils import SeleniumTestCase, retry diff --git a/tests/integration/test_outpost_kubernetes.py b/tests/integration/test_outpost_kubernetes.py index 099eddc87a..abd876046c 100644 --- a/tests/integration/test_outpost_kubernetes.py +++ b/tests/integration/test_outpost_kubernetes.py @@ -7,8 +7,8 @@ from django.test import TestCase from kubernetes.client import AppsV1Api from kubernetes.client.exceptions import OpenApiException +from authentik.common.config import CONFIG from authentik.core.tests.utils import create_test_flow -from authentik.lib.config import CONFIG from authentik.outposts.controllers.k8s.deployment import DeploymentReconciler from authentik.outposts.controllers.k8s.service import ServiceReconciler from authentik.outposts.controllers.k8s.triggers import NeedsUpdate