From d535a82372f88f0d9c0c35467b55014b40a7c30f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 23 Dec 2023 02:55:49 +0100 Subject: [PATCH] core: fix PropertyMapping context not being available in request context Signed-off-by: Jens Langhammer --- authentik/core/expression/evaluator.py | 1 + blueprints/system/providers-proxy.yaml | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/authentik/core/expression/evaluator.py b/authentik/core/expression/evaluator.py index 85e6ccbc4..480caea21 100644 --- a/authentik/core/expression/evaluator.py +++ b/authentik/core/expression/evaluator.py @@ -44,6 +44,7 @@ class PropertyMappingEvaluator(BaseEvaluator): if request: req.http_request = request self._context["request"] = req + req.context.update(**kwargs) self._context.update(**kwargs) self.dry_run = dry_run diff --git a/blueprints/system/providers-proxy.yaml b/blueprints/system/providers-proxy.yaml index 152ed3f44..2fd4db560 100644 --- a/blueprints/system/providers-proxy.yaml +++ b/blueprints/system/providers-proxy.yaml @@ -14,8 +14,11 @@ entries: expression: | # This mapping is used by the authentik proxy. It passes extra user attributes, # which are used for example for the HTTP-Basic Authentication mapping. + session_id = None + if "token" in request.context: + session_id = request.context.get("token").session_id return { - "sid": token.session_id, + "sid": session_id, "ak_proxy": { "user_attributes": request.user.group_attributes(request), "is_superuser": request.user.is_superuser,