Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Properly sign the http-redirect binding url, pysaml isn't clear about…
… this but it does work this way.
  • Loading branch information
Reece authored and Reece committed Apr 12, 2017
commit a49e2cc3526f62b926154eab689768e85370f505
9 changes: 5 additions & 4 deletions djangosaml2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def csrf_exempt(view_func):
from saml2.ident import code, decode
from saml2.sigver import MissingKey
from saml2.response import StatusError
from saml2.xmldsig import SIG_RSA_SHA1 # support for this is required by spec

from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
from djangosaml2.cache import StateCache
Expand Down Expand Up @@ -158,15 +159,15 @@ def login(request,

client = Saml2Client(conf)
http_response = None

logger.debug('Redirecting user to the IdP via %s binding.', binding)
if binding == BINDING_HTTP_REDIRECT:
try:
# we use sign kwarg to override in case of redirect binding
# otherwise pysaml2 may sign the xml for redirect which is incorrect
# do not sign the xml itself, instead us the sigalg to
# generate the signature as a URL param
session_id, result = client.prepare_for_authenticate(
entityid=selected_idp, relay_state=came_from,
binding=binding, sign=False)
binding=binding, sign=False, sigalg=SIG_RSA_SHA1)
except TypeError as e:
logger.error('Unable to know which IdP to use')
return HttpResponse(text_type(e))
Expand Down