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]