Skip to content

Commit 6b9faf5

Browse files
committed
Redefine NSMAP constant
1 parent c8717ff commit 6b9faf5

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/onelogin/saml2/constants.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ class OneLogin_Saml2_Constants(object):
5050
NS_XENC = 'http://www.w3.org/2001/04/xmlenc#'
5151
NS_DS = 'http://www.w3.org/2000/09/xmldsig#'
5252

53+
# Namespace Prefixes
54+
NS_PREFIX_SAML = 'saml'
55+
NS_PREFIX_SAMLP = 'samlp'
56+
NS_PREFIX_MD = 'md'
57+
NS_PREFIX_XS = 'xs'
58+
NS_PREFIX_XSI = 'xsi'
59+
NS_PREFIX_XENC = 'xenc'
60+
NS_PREFIX_DS = 'ds'
61+
62+
# Prefix:Namespace Mappings
63+
NSMAP = {
64+
NS_PREFIX_SAMLP: NS_SAMLP,
65+
NS_PREFIX_SAML: NS_SAML,
66+
NS_PREFIX_DS: NS_DS,
67+
NS_PREFIX_XENC: NS_XENC,
68+
NS_PREFIX_MD: NS_MD
69+
}
70+
5371
# Bindings
5472
BINDING_HTTP_POST = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
5573
BINDING_HTTP_REDIRECT = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
@@ -79,15 +97,6 @@ class OneLogin_Saml2_Constants(object):
7997
STATUS_PARTIAL_LOGOUT = 'urn:oasis:names:tc:SAML:2.0:status:PartialLogout'
8098
STATUS_PROXY_COUNT_EXCEEDED = 'urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded'
8199

82-
# Namespaces
83-
NSMAP = {
84-
'samlp': NS_SAMLP,
85-
'saml': NS_SAML,
86-
'md': NS_MD,
87-
'ds': NS_DS,
88-
'xenc': NS_XENC
89-
}
90-
91100
# Sign & Crypto
92101
SHA1 = 'http://www.w3.org/2000/09/xmldsig#sha1'
93102
SHA256 = 'http://www.w3.org/2001/04/xmlenc#sha256'

src/onelogin/saml2/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ def get_attributes(self):
531531
)
532532

533533
values = []
534-
for attr in attribute_node.iterchildren('{%s}AttributeValue' % OneLogin_Saml2_Constants.NSMAP['saml']):
534+
for attr in attribute_node.iterchildren('{%s}AttributeValue' % OneLogin_Saml2_Constants.NSMAP[OneLogin_Saml2_Constants.NS_PREFIX_SAML]):
535535
# Remove any whitespace (which may be present where attributes are
536536
# nested inside NameID children).
537537
if attr.text:
@@ -540,7 +540,7 @@ def get_attributes(self):
540540
values.append(text)
541541

542542
# Parse any nested NameID children
543-
for nameid in attr.iterchildren('{%s}NameID' % OneLogin_Saml2_Constants.NSMAP['saml']):
543+
for nameid in attr.iterchildren('{%s}NameID' % OneLogin_Saml2_Constants.NSMAP[OneLogin_Saml2_Constants.NS_PREFIX_SAML]):
544544
values.append({
545545
'NameID': {
546546
'Format': nameid.get('Format'),

0 commit comments

Comments
 (0)