Skip to content

Commit c3f51e3

Browse files
author
Roland Hedberg
committed
Allow the addition of SessionIndexes to a LogoutRequest
1 parent a941f1c commit c3f51e3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/saml2/client_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def create_authn_request(self, destination, vorg="", scoping=None,
253253
args["provider_name"] = self._my_name()
254254

255255
# Allow argument values either as class instances or as dictionaries
256+
# all of these have cardinality 0..1
256257
_msg = AuthnRequest()
257258
for param in ["scoping", "requested_authn_context", "conditions",
258259
"subject", "scoping"]:

src/saml2/entity.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from saml2.s_utils import success_status_factory
3636
from saml2.s_utils import decode_base64_and_inflate
3737
from saml2.s_utils import UnsupportedBinding
38-
from saml2.samlp import AuthnRequest
38+
from saml2.samlp import AuthnRequest, SessionIndex
3939
from saml2.samlp import AuthzDecisionQuery
4040
from saml2.samlp import AuthnQuery
4141
from saml2.samlp import AssertionIDRequest
@@ -673,7 +673,8 @@ def create_error_response(self, in_response_to, destination, info,
673673
def create_logout_request(self, destination, issuer_entity_id,
674674
subject_id=None, name_id=None,
675675
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):
677678
""" Constructs a LogoutRequest
678679
679680
:param destination: Destination of the request
@@ -689,6 +690,7 @@ def create_logout_request(self, destination, issuer_entity_id,
689690
:param consent: Whether the principal have given her consent
690691
:param extensions: Possible extensions
691692
:param sign: Whether the query should be signed or not.
693+
:param session_indexes: SessionIndex instances or just values
692694
:return: A LogoutRequest instance
693695
"""
694696

@@ -703,10 +705,20 @@ def create_logout_request(self, destination, issuer_entity_id,
703705
if not name_id:
704706
raise SAMLError("Missing subject identification")
705707

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+
706718
return self._message(LogoutRequest, destination, message_id,
707719
consent, extensions, sign, name_id=name_id,
708720
reason=reason, not_on_or_after=expire,
709-
issuer=self._issuer())
721+
issuer=self._issuer(), **args)
710722

711723
def create_logout_response(self, request, bindings=None, status=None,
712724
sign=False, issuer=None):

tools/make_metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import argparse
33
import os
44
import sys
5-
from saml2.s_utils import rndstr
65
from saml2.metadata import entity_descriptor, metadata_tostring_fix
76
from saml2.metadata import entities_descriptor
87
from saml2.metadata import sign_entity_descriptor

0 commit comments

Comments
 (0)