@@ -407,6 +407,7 @@ def echo_attributes(request,
407
407
"""Example view that echo the SAML attributes of an user"""
408
408
saml_session = get_saml_request_session (request )
409
409
state = StateCache (saml_session )
410
+ state .sync ()
410
411
conf = get_config (config_loader_path , request )
411
412
412
413
client = Saml2Client (conf , state_cache = state ,
@@ -428,12 +429,15 @@ def logout(request, config_loader_path=None):
428
429
This view initiates the SAML2 Logout request
429
430
using the pysaml2 library to create the LogoutRequest.
430
431
"""
432
+ _do_local_logout (request )
433
+
431
434
saml_session = get_saml_request_session (request )
432
435
state = StateCache (saml_session )
433
- conf = get_config (config_loader_path , request )
434
436
437
+ conf = get_config (config_loader_path , request )
435
438
client = Saml2Client (conf , state_cache = state ,
436
439
identity_cache = IdentityCache (saml_session ))
440
+
437
441
subject_id = _get_subject_id (saml_session )
438
442
if subject_id is None :
439
443
logger .warning (
@@ -450,8 +454,6 @@ def logout(request, config_loader_path=None):
450
454
state .sync ()
451
455
return HttpResponseRedirect (settings .LOGOUT_REDIRECT_URL )
452
456
453
- # user locally logged out for prudence, indipendently by IdP behaviour
454
- _do_local_logout (request )
455
457
state .sync ()
456
458
457
459
if not result :
@@ -499,7 +501,7 @@ def _do_local_logout(request):
499
501
500
502
501
503
def do_logout_service (request , data , binding , config_loader_path = None , next_page = None ,
502
- logout_error_template = 'djangosaml2/logout_error.html' ):
504
+ logout_error_template = 'djangosaml2/logout_error.html' ):
503
505
"""SAML Logout Response endpoint
504
506
505
507
The IdP will send the logout response to this view,
@@ -517,10 +519,11 @@ def do_logout_service(request, data, binding, config_loader_path=None, next_page
517
519
client = Saml2Client (conf , state_cache = state ,
518
520
identity_cache = IdentityCache (saml_session ))
519
521
522
+ state .sync ()
523
+
520
524
if 'SAMLResponse' in data : # we started the logout
521
525
logger .debug ('Receiving a logout response from the IdP' )
522
526
response = client .parse_logout_request_response (data ['SAMLResponse' ], binding )
523
- state .sync ()
524
527
return finish_logout (request , response , next_page = next_page )
525
528
526
529
elif 'SAMLRequest' in data : # logout started by the IdP
@@ -539,7 +542,6 @@ def do_logout_service(request, data, binding, config_loader_path=None, next_page
539
542
subject_id ,
540
543
binding ,
541
544
relay_state = data .get ('RelayState' , '' ))
542
- state .sync ()
543
545
544
546
# logout
545
547
_do_local_logout (request )
0 commit comments