Skip to content

Commit 809f94a

Browse files
authored
Merge pull request #122 from vkurup/upgrade-pysaml-vkurup
Upgrade to pysaml 4.5
2 parents 7110c3a + 3ed883b commit 809f94a

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

djangosaml2/tests/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def create_conf(sp_host='sp.example.com', idp_hosts=['idp.example.com'],
5353
},
5454
'required_attributes': ['uid'],
5555
'optional_attributes': ['eduPersonAffiliation'],
56-
'idp': {} # this is filled later
56+
'idp': {}, # this is filled later
57+
'want_response_signed': False,
5758
},
5859
},
5960

djangosaml2/views.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
import base64
1717
import logging
1818

19-
try:
20-
from xml.etree import ElementTree
21-
except ImportError:
22-
from elementtree import ElementTree
23-
2419
from django.conf import settings
2520
from django.contrib import auth
2621
from django.contrib.auth.decorators import login_required
@@ -185,9 +180,11 @@ def login(request,
185180
'sha256': SIG_RSA_SHA256}
186181
sig_alg_option = getattr(conf, '_sp_authn_requests_signed_alg', 'sha1')
187182
sigalg = sig_alg_option_map[sig_alg_option] if sign_requests else None
183+
nsprefix = get_namespace_prefixes()
188184
session_id, result = client.prepare_for_authenticate(
189185
entityid=selected_idp, relay_state=came_from,
190-
binding=binding, sign=False, sigalg=sigalg)
186+
binding=binding, sign=False, sigalg=sigalg,
187+
nsprefix=nsprefix)
191188
except TypeError as e:
192189
logger.error('Unable to know which IdP to use')
193190
return HttpResponse(text_type(e))
@@ -486,24 +483,16 @@ def metadata(request, config_loader_path=None, valid_for=None):
486483
content_type="text/xml; charset=utf8")
487484

488485

489-
def register_namespace_prefixes():
486+
def get_namespace_prefixes():
490487
from saml2 import md, saml, samlp
491488
try:
492489
from saml2 import xmlenc
493490
from saml2 import xmldsig
494491
except ImportError:
495492
import xmlenc
496493
import xmldsig
497-
prefixes = (('saml', saml.NAMESPACE),
498-
('samlp', samlp.NAMESPACE),
499-
('md', md.NAMESPACE),
500-
('ds', xmldsig.NAMESPACE),
501-
('xenc', xmlenc.NAMESPACE))
502-
if hasattr(ElementTree, 'register_namespace'):
503-
for prefix, namespace in prefixes:
504-
ElementTree.register_namespace(prefix, namespace)
505-
else:
506-
for prefix, namespace in prefixes:
507-
ElementTree._namespace_map[namespace] = prefix
508-
509-
register_namespace_prefixes()
494+
return {'saml': saml.NAMESPACE,
495+
'samlp': samlp.NAMESPACE,
496+
'md': md.NAMESPACE,
497+
'ds': xmldsig.NAMESPACE,
498+
'xenc': xmlenc.NAMESPACE}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def read(*rnames):
7272
'defusedxml>=0.4.1',
7373
'Django>=1.8',
7474
'enum34;python_version > "3" and python_version < "3.4"',
75-
'pysaml2==4.4.0',
75+
'pysaml2==4.5.0',
7676
],
7777
extras_require=extra,
7878
)

0 commit comments

Comments
 (0)