@@ -143,7 +143,7 @@ def operation(self, saml_msg, binding):
143143 saml_msg ["RelayState" ],
144144 encrypt_cert = _encrypt_cert , ** kwargs )
145145 except KeyError :
146- # Can live with no relay state # TODO or can we, for inacademia?
146+ # Can live with no relay state
147147 return self .do (saml_msg ["SAMLRequest" ], binding ,
148148 saml_msg ["RelayState" ], ** kwargs )
149149
@@ -211,10 +211,13 @@ def uri(self):
211211
212212 def not_authn (self , key , requested_authn_context ):
213213 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 )
217214
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 )
218221
219222# -----------------------------------------------------------------------------
220223
@@ -422,7 +425,8 @@ def post(self):
422425 saml_msg ["SAMLRequest" ], BINDING_HTTP_POST )
423426 _req = self .req_info .message
424427 if self .user :
425- if _req .force_authn :
428+ if _req .force_authn is not None and \
429+ _req .force_authn .lower () == 'true' :
426430 saml_msg ["req_info" ] = self .req_info
427431 key = self ._store_request (saml_msg )
428432 return self .not_authn (key , _req .requested_authn_context )
@@ -486,7 +490,7 @@ def ecp(self):
486490
487491
488492def do_authentication (environ , start_response , authn_context , key ,
489- redirect_uri ):
493+ redirect_uri , headers = None ):
490494 """
491495 Display the login form
492496 """
@@ -496,7 +500,7 @@ def do_authentication(environ, start_response, authn_context, key,
496500 if len (auth_info ):
497501 method , reference = auth_info [0 ]
498502 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 )
500504 else :
501505 resp = Unauthorized ("No usable authentication method" )
502506 return resp (environ , start_response )
@@ -513,15 +517,17 @@ def do_authentication(environ, start_response, authn_context, key,
513517
514518
515519def username_password_authn (environ , start_response , reference , key ,
516- redirect_uri ):
520+ redirect_uri , headers = None ):
517521 """
518522 Display the login form
519523 """
520524 logger .info ("The login page" )
521- headers = []
522525
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 )
525531
526532 argv = {
527533 "action" : "/verify" ,
0 commit comments