From 4d31c9cc11ed6fd96d72a2ffa38172b913c7b4bc Mon Sep 17 00:00:00 2001 From: Ashima Athri Date: Wed, 5 Oct 2016 17:09:04 -0400 Subject: [PATCH 1/2] Add a namespace for AttributeValue xsi:type value This fixes the issue when integrating with onelogin's python3-saml client: Element '{urn:oasis:names:tc:SAML:2.0:assertion}AttributeValue', attribute '{http://www.w3.org/2001/XMLSchema-instance}type': The QName value 'xs:string' has no corresponding namespace declaration in scope. --- src/saml2/saml.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/saml2/saml.py b/src/saml2/saml.py index 483611f1c..55fd65500 100644 --- a/src/saml2/saml.py +++ b/src/saml2/saml.py @@ -166,7 +166,9 @@ def set_type(self, typ): try: self.extension_attributes[XSI_TYPE] = typ + self.extension_attributes['xmlns:xs'] = XS_NAMESPACE except AttributeError: + self._extatt['xmlns:xs'] = XS_NAMESPACE self._extatt[XSI_TYPE] = typ def get_type(self): From b3cc7c4badd7c53e477eebba6fdba15f5294590d Mon Sep 17 00:00:00 2001 From: Ashima Athri Date: Thu, 6 Oct 2016 12:27:55 -0400 Subject: [PATCH 2/2] It's cleaner to conditionally add this attribute As per @jgehrcke's comment --- src/saml2/saml.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/saml2/saml.py b/src/saml2/saml.py index 55fd65500..35b7bd1a4 100644 --- a/src/saml2/saml.py +++ b/src/saml2/saml.py @@ -166,11 +166,16 @@ def set_type(self, typ): try: self.extension_attributes[XSI_TYPE] = typ - self.extension_attributes['xmlns:xs'] = XS_NAMESPACE except AttributeError: - self._extatt['xmlns:xs'] = XS_NAMESPACE self._extatt[XSI_TYPE] = typ + if typ.startswith('xs:'): + try: + self.extension_attributes['xmlns:xs'] = XS_NAMESPACE + except AttributeError: + self._extatt['xmlns:xs'] = XS_NAMESPACE + + def get_type(self): try: return self.extension_attributes[XSI_TYPE]