From d11721805a1623ec472ed1ea21b10d9a56293e29 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Wed, 15 Nov 2023 17:33:50 +0100 Subject: [PATCH] small fixes, runs Signed-off-by: Marc 'risson' Schmitt --- authentik/blueprints/apps.py | 11 ++++++++--- authentik/blueprints/v1/tasks.py | 2 +- authentik/brands/api.py | 8 ++++---- authentik/core/views/interface.py | 4 +++- authentik/root/celery.py | 2 +- authentik/root/settings.py | 2 +- authentik/tenants/migrations/0001_initial.py | 2 ++ schema.yml | 1 - .../ak-application-wizard-authentication-by-oauth.ts | 2 +- 9 files changed, 21 insertions(+), 13 deletions(-) diff --git a/authentik/blueprints/apps.py b/authentik/blueprints/apps.py index e63967e16..9151ef580 100644 --- a/authentik/blueprints/apps.py +++ b/authentik/blueprints/apps.py @@ -39,9 +39,14 @@ class ManagedAppConfig(AppConfig): if not meth_name.startswith(prefix): continue name = meth_name.replace(prefix, "") - tenants = Tenant.objects.all() - if meth_name.startswith(tenant_prefix): - tenants = Tenant.objects.get(schema_name=get_public_schema_name()) + tenants = Tenant.objects.filter(ready=True) + if not meth_name.startswith(tenant_prefix): + tenants = Tenant.objects.filter(schema_name=get_public_schema_name()) + try: + tenants = list(tenants) + except (DatabaseError, ProgrammingError, InternalError) as exc: + self._logger.debug("Failed to get tenants to run reconcile", name=name, exc=exc) + continue for tenant in tenants: with tenant: try: diff --git a/authentik/blueprints/v1/tasks.py b/authentik/blueprints/v1/tasks.py index aad3a1ca8..49a3b3499 100644 --- a/authentik/blueprints/v1/tasks.py +++ b/authentik/blueprints/v1/tasks.py @@ -76,7 +76,7 @@ class BlueprintEventHandler(FileSystemEventHandler): return if event.is_directory: return - for tenant in Tenant.objects.all(): + for tenant in Tenant.objects.filter(ready=True): with tenant: if isinstance(event, FileCreatedEvent): LOGGER.debug("new blueprint file created, starting discovery") diff --git a/authentik/brands/api.py b/authentik/brands/api.py index da88e31d3..80e6f3d20 100644 --- a/authentik/brands/api.py +++ b/authentik/brands/api.py @@ -69,13 +69,13 @@ class Themes(models.TextChoices): DARK = "dark" +def get_default_ui_footer_links(): + return get_current_tenant().footer_links + + class CurrentBrandSerializer(PassiveSerializer): """Partial brand information for styling""" - @staticmethod - def get_default_ui_footer_links(): - return get_current_tenant().footer_links - matched_domain = CharField(source="domain") branding_title = CharField() branding_logo = CharField() diff --git a/authentik/core/views/interface.py b/authentik/core/views/interface.py index 03d483183..7144a4a0d 100644 --- a/authentik/core/views/interface.py +++ b/authentik/core/views/interface.py @@ -17,7 +17,9 @@ class InterfaceView(TemplateView): """Base interface view""" def get_context_data(self, **kwargs: Any) -> dict[str, Any]: - kwargs["config_json"] = dumps(ConfigView(request=Request(self.request)).get_config().data) + kwargs["config_json"] = dumps( + ConfigView(request=Request(self.request)).get_config(self.request).data + ) kwargs["brand_json"] = dumps(CurrentBrandSerializer(self.request.brand).data) kwargs["version_family"] = f"{LOCAL_VERSION.major}.{LOCAL_VERSION.minor}" kwargs["version_subdomain"] = f"version-{LOCAL_VERSION.major}-{LOCAL_VERSION.minor}" diff --git a/authentik/root/celery.py b/authentik/root/celery.py index e49d88a8d..d88cb44d9 100644 --- a/authentik/root/celery.py +++ b/authentik/root/celery.py @@ -119,7 +119,7 @@ def worker_ready_hook(*args, **kwargs): _run_task(task) for task in _get_startup_tasks_all_tenants(): - for tenant in Tenant.objects.all(): + for tenant in Tenant.objects.filter(ready=True): with tenant: _run_task(task) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 1cd85df6e..60b5cc248 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -228,7 +228,7 @@ MIDDLEWARE = [ "django_tenants.middleware.default.DefaultTenantMiddleware", "authentik.root.middleware.LoggingMiddleware", "django_prometheus.middleware.PrometheusBeforeMiddleware", - "authentik.brands.middleware.TenantMiddleware", + "authentik.brands.middleware.BrandMiddleware", "authentik.root.middleware.SessionMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "authentik.core.middleware.RequestIDMiddleware", diff --git a/authentik/tenants/migrations/0001_initial.py b/authentik/tenants/migrations/0001_initial.py index 91baaa6f5..db3ed2fda 100644 --- a/authentik/tenants/migrations/0001_initial.py +++ b/authentik/tenants/migrations/0001_initial.py @@ -16,6 +16,7 @@ def create_default_tenant(apps, schema_editor): tenant = Tenant.objects.using(db_alias).create( schema_name="public", name="Default", + ready=True, avatars=CONFIG.get("avatars", "gravatar,initials"), default_user_change_name=CONFIG.get_bool("default_user_change_name", True), default_user_change_email=CONFIG.get_bool("default_user_change_email", False), @@ -54,6 +55,7 @@ class Migration(migrations.Migration): ), ), ("name", models.TextField()), + ("ready", models.BooleanField(default=False)), ( "avatars", models.TextField( diff --git a/schema.yml b/schema.yml index 2dc7d8343..683a1f2d8 100644 --- a/schema.yml +++ b/schema.yml @@ -30169,7 +30169,6 @@ components: items: $ref: '#/components/schemas/FooterLink' readOnly: true - default: [] ui_theme: allOf: - $ref: '#/components/schemas/UiThemeEnum' diff --git a/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts b/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts index 88646df35..51fb7ca28 100644 --- a/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts +++ b/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts @@ -1,5 +1,5 @@ import "@goauthentik/admin/common/ak-crypto-certificate-search"; -import "@goauthentik/admin/common/ak-flow-search/ak-branted-flow-search"; +import "@goauthentik/admin/common/ak-flow-search/ak-branded-flow-search"; import { clientTypeOptions, issuerModeOptions,