@@ -143,7 +143,7 @@ def operation(self, saml_msg, binding):
143
143
saml_msg ["RelayState" ],
144
144
encrypt_cert = _encrypt_cert , ** kwargs )
145
145
except KeyError :
146
- # Can live with no relay state # TODO or can we, for inacademia?
146
+ # Can live with no relay state
147
147
return self .do (saml_msg ["SAMLRequest" ], binding ,
148
148
saml_msg ["RelayState" ], ** kwargs )
149
149
@@ -211,10 +211,13 @@ def uri(self):
211
211
212
212
def not_authn (self , key , requested_authn_context ):
213
213
ruri = geturl (self .environ , query = False )
214
- return do_authentication (self .environ , self .start_response ,
215
- authn_context = requested_authn_context ,
216
- key = key , redirect_uri = ruri )
217
214
215
+ kwargs = dict (authn_context = requested_authn_context , key = key , redirect_uri = ruri )
216
+ # Clear cookie, if it already exists
217
+ kaka = delete_cookie (self .environ , "idpauthn" )
218
+ if kaka :
219
+ kwargs ["headers" ] = [kaka ]
220
+ return do_authentication (self .environ , self .start_response , ** kwargs )
218
221
219
222
# -----------------------------------------------------------------------------
220
223
@@ -422,7 +425,8 @@ def post(self):
422
425
saml_msg ["SAMLRequest" ], BINDING_HTTP_POST )
423
426
_req = self .req_info .message
424
427
if self .user :
425
- if _req .force_authn :
428
+ if _req .force_authn is not None and \
429
+ _req .force_authn .lower () == 'true' :
426
430
saml_msg ["req_info" ] = self .req_info
427
431
key = self ._store_request (saml_msg )
428
432
return self .not_authn (key , _req .requested_authn_context )
@@ -486,7 +490,7 @@ def ecp(self):
486
490
487
491
488
492
def do_authentication (environ , start_response , authn_context , key ,
489
- redirect_uri ):
493
+ redirect_uri , headers = None ):
490
494
"""
491
495
Display the login form
492
496
"""
@@ -496,7 +500,7 @@ def do_authentication(environ, start_response, authn_context, key,
496
500
if len (auth_info ):
497
501
method , reference = auth_info [0 ]
498
502
logger .debug ("Authn chosen: %s (ref=%s)" % (method , reference ))
499
- return method (environ , start_response , reference , key , redirect_uri )
503
+ return method (environ , start_response , reference , key , redirect_uri , headers )
500
504
else :
501
505
resp = Unauthorized ("No usable authentication method" )
502
506
return resp (environ , start_response )
@@ -513,15 +517,17 @@ def do_authentication(environ, start_response, authn_context, key,
513
517
514
518
515
519
def username_password_authn (environ , start_response , reference , key ,
516
- redirect_uri ):
520
+ redirect_uri , headers = None ):
517
521
"""
518
522
Display the login form
519
523
"""
520
524
logger .info ("The login page" )
521
- headers = []
522
525
523
- resp = Response (mako_template = "login.mako" , template_lookup = LOOKUP ,
524
- headers = headers )
526
+ kwargs = dict (mako_template = "login.mako" , template_lookup = LOOKUP )
527
+ if headers :
528
+ kwargs ["headers" ] = headers
529
+
530
+ resp = Response (** kwargs )
525
531
526
532
argv = {
527
533
"action" : "/verify" ,
0 commit comments