Skip to content

Commit 2f2c9d8

Browse files
authored
Merge pull request #66 from WebSpider/master
Adding support for SHA256 signing
2 parents b479d0d + ce04e77 commit 2f2c9d8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

djangosaml2/views.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def csrf_exempt(view_func):
4949
from saml2.sigver import MissingKey
5050
from saml2.s_utils import UnsupportedBinding
5151
from saml2.response import StatusError
52-
from saml2.xmldsig import SIG_RSA_SHA1 # support for this is required by spec
52+
from saml2.xmldsig import SIG_RSA_SHA1, SIG_RSA_SHA256 # support for SHA1 is required by spec
5353

5454
from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
5555
from djangosaml2.cache import StateCache
@@ -168,9 +168,12 @@ def login(request,
168168
logger.debug('Redirecting user to the IdP via %s binding.', binding)
169169
if binding == BINDING_HTTP_REDIRECT:
170170
try:
171-
# do not sign the xml itself, instead us the sigalg to
171+
# do not sign the xml itself, instead use the sigalg to
172172
# generate the signature as a URL param
173-
sigalg = SIG_RSA_SHA1 if sign_requests else None
173+
sig_alg_option_map = {'sha1': SIG_RSA_SHA1,
174+
'sha256': SIG_RSA_SHA256}
175+
sig_alg_option = getattr(conf, '_sp_authn_requests_signed_alg', 'sha1')
176+
sigalg = sig_alg_option_map[sig_alg_option] if sign_requests else None
174177
session_id, result = client.prepare_for_authenticate(
175178
entityid=selected_idp, relay_state=came_from,
176179
binding=binding, sign=False, sigalg=sigalg)

0 commit comments

Comments
 (0)