From 171ec4106919f96ad6588d3acc5858a7e962f4a8 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 14 Jan 2020 12:03:47 +0000 Subject: [PATCH] Hopefully, fix NameID parsing --- matrix_synapse_saml_mozilla/mapping_provider.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matrix_synapse_saml_mozilla/mapping_provider.py b/matrix_synapse_saml_mozilla/mapping_provider.py index 87f2d86..edd79ab 100644 --- a/matrix_synapse_saml_mozilla/mapping_provider.py +++ b/matrix_synapse_saml_mozilla/mapping_provider.py @@ -60,7 +60,11 @@ class SamlMappingProvider(object): ): """Extracts the remote user id from the SAML response""" if self._config.use_name_id_for_remote_uid: - return saml_response.name_id + name_id = saml_response.name_id + if not name_id: + logger.warning("SAML2 response lacks a NameID field") + raise CodeMessageException(400, "'NameID' not in SAML2 response") + return name_id.text else: try: return saml_response.ava["uid"][0]