Skip to content

Commit 441b8d1

Browse files
committed
Adding support for SHA255 signing
1 parent b479d0d commit 441b8d1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

djangosaml2/views.py

Lines changed: 5 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,11 @@ 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 = getattr(conf, '_sp_authn_requests_signed_alg', False)
174+
sigalg = SIG_RSA_SHA1 if sign_requests and sig_alg == 'sha1' else None
175+
sigalg = SIG_RSA_SHA256 if sign_requests and sig_alg == 'sha256' else None
174176
session_id, result = client.prepare_for_authenticate(
175177
entityid=selected_idp, relay_state=came_from,
176178
binding=binding, sign=False, sigalg=sigalg)

0 commit comments

Comments
 (0)