diff --git a/authentik/api/templates/api/browser.html b/authentik/api/templates/api/browser.html index 2ea149f72..0f29ea4be 100644 --- a/authentik/api/templates/api/browser.html +++ b/authentik/api/templates/api/browser.html @@ -3,7 +3,7 @@ {% load static %} {% block title %} -API Browser - {{ config.authentik.branding.title }} +API Browser - {{ tenant.branding_title }} {% endblock %} {% block head %} diff --git a/authentik/api/v2/config.py b/authentik/api/v2/config.py index d1f45167a..37b5287dd 100644 --- a/authentik/api/v2/config.py +++ b/authentik/api/v2/config.py @@ -14,13 +14,6 @@ from authentik.core.api.utils import PassiveSerializer from authentik.lib.config import CONFIG -class FooterLinkSerializer(PassiveSerializer): - """Links returned in Config API""" - - href = CharField(read_only=True) - name = CharField(read_only=True) - - class Capabilities(models.TextChoices): """Define capabilities which influence which APIs can/should be used""" @@ -30,10 +23,6 @@ class Capabilities(models.TextChoices): class ConfigSerializer(PassiveSerializer): """Serialize authentik Config into DRF Object""" - branding_logo = CharField(read_only=True) - branding_title = CharField(read_only=True) - ui_footer_links = ListField(child=FooterLinkSerializer(), read_only=True) - error_reporting_enabled = BooleanField(read_only=True) error_reporting_environment = CharField(read_only=True) error_reporting_send_pii = BooleanField(read_only=True) @@ -59,12 +48,9 @@ class ConfigView(APIView): """Retrive public configuration options""" config = ConfigSerializer( { - "branding_logo": CONFIG.y("authentik.branding.logo"), - "branding_title": CONFIG.y("authentik.branding.title"), "error_reporting_enabled": CONFIG.y("error_reporting.enabled"), "error_reporting_environment": CONFIG.y("error_reporting.environment"), "error_reporting_send_pii": CONFIG.y("error_reporting.send_pii"), - "ui_footer_links": CONFIG.y("authentik.footer_links"), "capabilities": self.get_capabilities(), } ) diff --git a/authentik/api/v2/urls.py b/authentik/api/v2/urls.py index 6dce33066..dade31d5e 100644 --- a/authentik/api/v2/urls.py +++ b/authentik/api/v2/urls.py @@ -100,6 +100,7 @@ from authentik.stages.user_delete.api import UserDeleteStageViewSet from authentik.stages.user_login.api import UserLoginStageViewSet from authentik.stages.user_logout.api import UserLogoutStageViewSet from authentik.stages.user_write.api import UserWriteStageViewSet +from authentik.tenants.api import TenantViewSet router = routers.DefaultRouter() @@ -111,6 +112,7 @@ router.register("core/groups", GroupViewSet) router.register("core/users", UserViewSet) router.register("core/user_consent", UserConsentViewSet) router.register("core/tokens", TokenViewSet) +router.register("core/tenants", TenantViewSet) router.register("outposts/instances", OutpostViewSet) router.register("outposts/service_connections/all", ServiceConnectionViewSet) diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index f36ecc258..566a8d39a 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -32,7 +32,7 @@ from authentik.core.middleware import ( ) from authentik.core.models import Token, TokenIntents, User from authentik.events.models import EventAction -from authentik.flows.models import Flow, FlowDesignation +from authentik.tenants.models import Tenant class UserSerializer(ModelSerializer): @@ -179,8 +179,9 @@ class UserViewSet(ModelViewSet): # pylint: disable=invalid-name, unused-argument def recovery(self, request: Request, pk: int) -> Response: """Create a temporary link that a user can use to recover their accounts""" + tenant: Tenant = request._request.tenant # Check that there is a recovery flow, if not return an error - flow = Flow.with_policy(request, designation=FlowDesignation.RECOVERY) + flow = tenant.flow_recovery if not flow: raise Http404 user: User = self.get_object() @@ -191,7 +192,8 @@ class UserViewSet(ModelViewSet): ) querystring = urlencode({"token": token.key}) link = request.build_absolute_uri( - reverse_lazy("authentik_flows:default-recovery") + f"?{querystring}" + reverse_lazy("authentik_core:if-flow", kwargs={"flow_slug": flow.slug}) + + f"?{querystring}" ) return Response({"link": link}) diff --git a/authentik/core/middleware.py b/authentik/core/middleware.py index 1f09555b7..64400b64b 100644 --- a/authentik/core/middleware.py +++ b/authentik/core/middleware.py @@ -42,10 +42,14 @@ class RequestIDMiddleware: if not hasattr(request, "request_id"): request_id = uuid4().hex setattr(request, "request_id", request_id) - LOCAL.authentik = {"request_id": request_id} + LOCAL.authentik = { + "request_id": request_id, + "host": request.get_host(), + } response = self.get_response(request) response[RESPONSE_HEADER_ID] = request.request_id del LOCAL.authentik["request_id"] + del LOCAL.authentik["host"] return response @@ -54,4 +58,5 @@ def structlog_add_request_id(logger: Logger, method_name: str, event_dict): """If threadlocal has authentik defined, add request_id to log""" if hasattr(LOCAL, "authentik"): event_dict["request_id"] = LOCAL.authentik.get("request_id", "") + event_dict["host"] = LOCAL.authentik.get("host", "") return event_dict diff --git a/authentik/core/templates/base/skeleton.html b/authentik/core/templates/base/skeleton.html index 694600b0f..47e6731e3 100644 --- a/authentik/core/templates/base/skeleton.html +++ b/authentik/core/templates/base/skeleton.html @@ -7,7 +7,7 @@ - {% block title %}{% trans title|default:config.authentik.branding.title %}{% endblock %} + {% block title %}{% trans title|default:tenant.branding_title %}{% endblock %} diff --git a/authentik/core/templates/login/base_full.html b/authentik/core/templates/login/base_full.html index 347036a92..b236bb7a7 100644 --- a/authentik/core/templates/login/base_full.html +++ b/authentik/core/templates/login/base_full.html @@ -26,10 +26,7 @@
- authentik icon - {% if config.authentik.branding.title_show %} -

{{ config.authentik.branding.title }}

- {% endif %} + authentik icon
{% block main_container %} @@ -49,12 +46,12 @@
diff --git a/web/src/routes.ts b/web/src/routes.ts index e3f909576..e159c6d47 100644 --- a/web/src/routes.ts +++ b/web/src/routes.ts @@ -25,10 +25,11 @@ import "./pages/stages/invitation/InvitationListPage"; import "./pages/stages/prompt/PromptListPage"; import "./pages/stages/StageListPage"; import "./pages/system-tasks/SystemTaskListPage"; +import "./pages/tenants/TenantListPage"; import "./pages/tokens/TokenListPage"; +import "./pages/user-settings/UserSettingsPage"; import "./pages/users/UserListPage"; import "./pages/users/UserViewPage"; -import "./pages/user-settings/UserSettingsPage"; export const ROUTES: Route[] = [ // Prevent infinite Shell loops @@ -51,6 +52,7 @@ export const ROUTES: Route[] = [ }), new Route(new RegExp("^/core/property-mappings$"), html``), new Route(new RegExp("^/core/tokens$"), html``), + new Route(new RegExp("^/core/tenants$"), html``), new Route(new RegExp("^/policy/policies$"), html``), new Route(new RegExp("^/identity/groups$"), html``), new Route(new RegExp("^/identity/users$"), html``),