diff --git a/authentik/brands/api.py b/authentik/brands/api.py index 2f0486a688ed..5f730e040380 100644 --- a/authentik/brands/api.py +++ b/authentik/brands/api.py @@ -84,8 +84,8 @@ class CurrentBrandSerializer(PassiveSerializer): matched_domain = CharField(source="domain") branding_title = CharField() - branding_logo = CharField() - branding_favicon = CharField() + branding_logo = CharField(source="branding_logo_url") + branding_favicon = CharField(source="branding_favicon_url") ui_footer_links = ListField( child=FooterLinkSerializer(), read_only=True, diff --git a/authentik/brands/models.py b/authentik/brands/models.py index 3a7bc775cf55..12e975b1de1e 100644 --- a/authentik/brands/models.py +++ b/authentik/brands/models.py @@ -10,6 +10,7 @@ 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() @@ -71,6 +72,18 @@ class Brand(SerializerModel): ) attributes = models.JSONField(default=dict, blank=True) + def branding_logo_url(self) -> str: + """Get branding_logo with the correct prefix""" + if self.branding_logo.startswith("/static"): + return CONFIG.get("web.path", "/")[:-1] + self.branding_logo + return self.branding_logo + + def branding_favicon_url(self) -> str: + """Get branding_favicon with the correct prefix""" + if self.branding_favicon.startswith("/static"): + return CONFIG.get("web.path", "/")[:-1] + self.branding_favicon + return self.branding_favicon + @property def serializer(self) -> Serializer: from authentik.brands.api import BrandSerializer diff --git a/authentik/core/templates/base/header_js.html b/authentik/core/templates/base/header_js.html index 4e1b53c2fa73..944bf587edbc 100644 --- a/authentik/core/templates/base/header_js.html +++ b/authentik/core/templates/base/header_js.html @@ -9,6 +9,9 @@ versionFamily: "{{ version_family }}", versionSubdomain: "{{ version_subdomain }}", build: "{{ build }}", + api: { + base: "{{ base_url }}", + }, }; window.addEventListener("DOMContentLoaded", function () { {% for message in messages %} diff --git a/authentik/core/templates/base/skeleton.html b/authentik/core/templates/base/skeleton.html index 074fcc15561a..e2f063b071b7 100644 --- a/authentik/core/templates/base/skeleton.html +++ b/authentik/core/templates/base/skeleton.html @@ -9,8 +9,8 @@ {% block title %}{% trans title|default:brand.branding_title %}{% endblock %} - - + + {% block head_before %} {% endblock %} diff --git a/authentik/core/templates/login/base_full.html b/authentik/core/templates/login/base_full.html index 483bae724567..cbab6c2ed529 100644 --- a/authentik/core/templates/login/base_full.html +++ b/authentik/core/templates/login/base_full.html @@ -4,7 +4,7 @@ {% load i18n %} {% block head_before %} - + {% include "base/header_js.html" %} @@ -13,7 +13,7 @@ {% block head %}