35
35
from saml2 .s_utils import success_status_factory
36
36
from saml2 .s_utils import decode_base64_and_inflate
37
37
from saml2 .s_utils import UnsupportedBinding
38
- from saml2 .samlp import AuthnRequest
38
+ from saml2 .samlp import AuthnRequest , SessionIndex
39
39
from saml2 .samlp import AuthzDecisionQuery
40
40
from saml2 .samlp import AuthnQuery
41
41
from saml2 .samlp import AssertionIDRequest
@@ -673,7 +673,8 @@ def create_error_response(self, in_response_to, destination, info,
673
673
def create_logout_request (self , destination , issuer_entity_id ,
674
674
subject_id = None , name_id = None ,
675
675
reason = None , expire = None , message_id = 0 ,
676
- consent = None , extensions = None , sign = False ):
676
+ consent = None , extensions = None , sign = False ,
677
+ session_indexes = None ):
677
678
""" Constructs a LogoutRequest
678
679
679
680
:param destination: Destination of the request
@@ -689,6 +690,7 @@ def create_logout_request(self, destination, issuer_entity_id,
689
690
:param consent: Whether the principal have given her consent
690
691
:param extensions: Possible extensions
691
692
:param sign: Whether the query should be signed or not.
693
+ :param session_indexes: SessionIndex instances or just values
692
694
:return: A LogoutRequest instance
693
695
"""
694
696
@@ -703,10 +705,20 @@ def create_logout_request(self, destination, issuer_entity_id,
703
705
if not name_id :
704
706
raise SAMLError ("Missing subject identification" )
705
707
708
+ args = {}
709
+ if session_indexes :
710
+ sis = []
711
+ for si in session_indexes :
712
+ if isinstance (si , SessionIndex ):
713
+ sis .append (si )
714
+ else :
715
+ sis .append (SessionIndex (text = si ))
716
+ args ["session_index" ] = sis
717
+
706
718
return self ._message (LogoutRequest , destination , message_id ,
707
719
consent , extensions , sign , name_id = name_id ,
708
720
reason = reason , not_on_or_after = expire ,
709
- issuer = self ._issuer ())
721
+ issuer = self ._issuer (), ** args )
710
722
711
723
def create_logout_response (self , request , bindings = None , status = None ,
712
724
sign = False , issuer = None ):
0 commit comments