Skip to content

Commit ad8e8cb

Browse files
author
Roland Hedberg
committed
Check for logout
1 parent 3c38cef commit ad8e8cb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

example/sp-wsgi/sp.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from saml2.response import StatusError
3939
from saml2.response import VerificationError
4040
from saml2.s_utils import UnknownPrincipal
41+
from saml2.s_utils import decode_base64_and_inflate
4142
from saml2.s_utils import UnsupportedBinding
4243
from saml2.s_utils import sid
4344
from saml2.s_utils import rndstr
@@ -633,8 +634,18 @@ def __init__(self, sp, environ, start_response, cache=None):
633634
self.sp = sp
634635
self.cache = cache
635636

636-
def do(self, response, binding, relay_state="", mtype="response"):
637-
req_info = self.sp.parse_logout_request_response(response, binding)
637+
def do(self, message, binding, relay_state="", mtype="response"):
638+
try:
639+
txt = decode_base64_and_inflate(message)
640+
is_logout_request = 'LogoutRequest' in txt.split('>', 1)[0]
641+
except: # TODO: parse the XML correctly
642+
is_logout_request = False
643+
644+
if is_logout_request:
645+
self.sp.parse_logout_request(message, binding)
646+
else:
647+
self.sp.parse_logout_request_response(message, binding)
648+
638649
return finish_logout(self.environ, self.start_response)
639650

640651
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)