From f7b9de1261a07d08c0da3295cdab225743df2536 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 12 Jul 2020 18:40:43 +0200 Subject: [PATCH] */saml: fix MetadataProcessor having generic namespace prefixes --- passbook/providers/saml/processors/metadata.py | 5 ++--- passbook/sources/saml/processors/metadata.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/passbook/providers/saml/processors/metadata.py b/passbook/providers/saml/processors/metadata.py index a7f1a6375..343de6fd2 100644 --- a/passbook/providers/saml/processors/metadata.py +++ b/passbook/providers/saml/processors/metadata.py @@ -1,10 +1,9 @@ """SAML Identity Provider Metadata Processor""" from typing import Iterator, Optional -from defusedxml import ElementTree from django.http import HttpRequest from django.shortcuts import reverse -from lxml.etree import Element, SubElement # nosec +from lxml.etree import Element, SubElement, tostring # nosec from signxml.util import strip_pem_header from passbook.providers.saml.models import SAMLProvider @@ -106,4 +105,4 @@ class MetadataProcessor: for binding in self.get_bindings(): idp_sso_descriptor.append(binding) - return ElementTree.tostring(entity_descriptor).decode() + return tostring(entity_descriptor).decode() diff --git a/passbook/sources/saml/processors/metadata.py b/passbook/sources/saml/processors/metadata.py index 6d7e7c576..05747f88f 100644 --- a/passbook/sources/saml/processors/metadata.py +++ b/passbook/sources/saml/processors/metadata.py @@ -3,7 +3,7 @@ from typing import Iterator, Optional from defusedxml import ElementTree from django.http import HttpRequest -from lxml.etree import Element, SubElement # nosec +from lxml.etree import Element, SubElement, tostring # nosec from signxml.util import strip_pem_header from passbook.sources.saml.models import SAMLSource @@ -75,7 +75,7 @@ class MetadataProcessor: ] = "urn:oasis:names:tc:SAML:2.0:protocol" signing_descriptor = self.get_signing_key_descriptor() - if signing_descriptor: + if signing_descriptor is not None: sp_sso_descriptor.append(signing_descriptor) for name_id_format in self.get_name_id_formats(): @@ -91,4 +91,4 @@ class MetadataProcessor: self.http_request ) - return ElementTree.tostring(entity_descriptor).decode() + return tostring(entity_descriptor).decode()