Skip to content

Commit b6a428c

Browse files
ReeceReece
authored andcommitted
Remove big warning, signing http-redirect works now. Only sign if setting says to.
1 parent a49e2cc commit b6a428c

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

djangosaml2/views.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,6 @@ def login(request,
138138
'came_from': came_from,
139139
})
140140

141-
# Choose binding (REDIRECT vs. POST).
142-
# When authn_requests_signed is turned on, HTTP Redirect binding cannot be
143-
# used the same way as without signatures; proper usage in this case involves
144-
# stripping out the signature from SAML XML message and creating a new
145-
# signature, following precise steps defined in the SAML2.0 standard.
146-
#
147-
# It is not feasible to implement this since we wouldn't be able to use an
148-
# external (xmlsec1) library to handle the signatures - more (higher level)
149-
# context is needed in order to create such signature (like the value of
150-
# RelayState parameter).
151-
#
152-
# Therefore it is much easier to use the HTTP POST binding in this case, as
153-
# it can relay the whole signed SAML message as is, without the need to
154-
# manipulate the signature or the XML message itself.
155-
#
156-
# Read more in the official SAML2 specs (3.4.4.1):
157-
# http://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf
158141
binding = BINDING_HTTP_POST if getattr(conf, '_sp_authn_requests_signed', False) else BINDING_HTTP_REDIRECT
159142

160143
client = Saml2Client(conf)
@@ -165,9 +148,10 @@ def login(request,
165148
try:
166149
# do not sign the xml itself, instead us the sigalg to
167150
# generate the signature as a URL param
151+
sigalg = SIG_RSA_SHA1 if getattr(conf, '_sp_authn_requests_signed', False) else None
168152
session_id, result = client.prepare_for_authenticate(
169153
entityid=selected_idp, relay_state=came_from,
170-
binding=binding, sign=False, sigalg=SIG_RSA_SHA1)
154+
binding=binding, sign=False, sigalg=sigalg)
171155
except TypeError as e:
172156
logger.error('Unable to know which IdP to use')
173157
return HttpResponse(text_type(e))

0 commit comments

Comments
 (0)