Skip to content

Commit a49e2cc

Browse files
ReeceReece
authored andcommitted
Properly sign the http-redirect binding url, pysaml isn't clear about this but it does work this way.
1 parent e47b2c4 commit a49e2cc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

djangosaml2/views.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def csrf_exempt(view_func):
4848
from saml2.ident import code, decode
4949
from saml2.sigver import MissingKey
5050
from saml2.response import StatusError
51+
from saml2.xmldsig import SIG_RSA_SHA1 # support for this is required by spec
5152

5253
from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
5354
from djangosaml2.cache import StateCache
@@ -158,15 +159,15 @@ def login(request,
158159

159160
client = Saml2Client(conf)
160161
http_response = None
161-
162+
162163
logger.debug('Redirecting user to the IdP via %s binding.', binding)
163164
if binding == BINDING_HTTP_REDIRECT:
164165
try:
165-
# we use sign kwarg to override in case of redirect binding
166-
# otherwise pysaml2 may sign the xml for redirect which is incorrect
166+
# do not sign the xml itself, instead us the sigalg to
167+
# generate the signature as a URL param
167168
session_id, result = client.prepare_for_authenticate(
168169
entityid=selected_idp, relay_state=came_from,
169-
binding=binding, sign=False)
170+
binding=binding, sign=False, sigalg=SIG_RSA_SHA1)
170171
except TypeError as e:
171172
logger.error('Unable to know which IdP to use')
172173
return HttpResponse(text_type(e))

0 commit comments

Comments
 (0)