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"}, + )