@@ -138,23 +138,6 @@ def login(request,
138
138
'came_from' : came_from ,
139
139
})
140
140
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
158
141
binding = BINDING_HTTP_POST if getattr (conf , '_sp_authn_requests_signed' , False ) else BINDING_HTTP_REDIRECT
159
142
160
143
client = Saml2Client (conf )
@@ -165,9 +148,10 @@ def login(request,
165
148
try :
166
149
# do not sign the xml itself, instead us the sigalg to
167
150
# generate the signature as a URL param
151
+ sigalg = SIG_RSA_SHA1 if getattr (conf , '_sp_authn_requests_signed' , False ) else None
168
152
session_id , result = client .prepare_for_authenticate (
169
153
entityid = selected_idp , relay_state = came_from ,
170
- binding = binding , sign = False , sigalg = SIG_RSA_SHA1 )
154
+ binding = binding , sign = False , sigalg = sigalg )
171
155
except TypeError as e :
172
156
logger .error ('Unable to know which IdP to use' )
173
157
return HttpResponse (text_type (e ))
0 commit comments