From 6ea57921f256a45583c602b539e69d4fa9a901d2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 24 Oct 2022 21:42:24 +0200 Subject: [PATCH] sources/saml: set username field to name_id attribute Signed-off-by: Jens Langhammer --- authentik/sources/saml/processors/response.py | 1 + authentik/sources/saml/tests/test_response.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/authentik/sources/saml/processors/response.py b/authentik/sources/saml/processors/response.py index 6b5a4682b..173b4b070 100644 --- a/authentik/sources/saml/processors/response.py +++ b/authentik/sources/saml/processors/response.py @@ -216,6 +216,7 @@ class ResponseProcessor: # Flatten all lists in the dict for key, value in attributes.items(): attributes[key] = BaseEvaluator.expr_flatten(value) + attributes["username"] = self._get_name_id().text return attributes def prepare_flow_manager(self) -> SourceFlowManager: diff --git a/authentik/sources/saml/tests/test_response.py b/authentik/sources/saml/tests/test_response.py index 5cbd11ab8..cf48f532e 100644 --- a/authentik/sources/saml/tests/test_response.py +++ b/authentik/sources/saml/tests/test_response.py @@ -109,4 +109,7 @@ class TestResponseProcessor(TestCase): parser = ResponseProcessor(self.source, request) parser.parse() sfm = parser.prepare_flow_manager() - self.assertEqual(sfm.enroll_info, {"email": "foo@bar.baz", "name": "foo", "sn": "bar"}) + self.assertEqual( + sfm.enroll_info, + {"email": "foo@bar.baz", "name": "foo", "sn": "bar", "username": "jens@beryju.org"}, + )