sources/saml: set username field to name_id attribute

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-10-24 21:42:24 +02:00
parent c7ea4b5a7f
commit 6ea57921f2
2 changed files with 5 additions and 1 deletions

View file

@ -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:

View file

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