summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexample/idp2/idp.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/example/idp2/idp.py b/example/idp2/idp.py
index 8e6af4f3..fc978054 100755
--- a/example/idp2/idp.py
+++ b/example/idp2/idp.py
@@ -570,9 +570,8 @@ class SLO(Service):
def do(self, request, binding, relay_state="", encrypt_cert=None):
logger.info("--- Single Log Out Service ---")
try:
- _, body = request.split("\n")
- logger.debug("req: '%s'" % body)
- req_info = IDP.parse_logout_request(body, binding)
+ logger.debug("req: '%s'" % request)
+ req_info = IDP.parse_logout_request(request, binding)
except Exception as exc:
logger.error("Bad request: %s" % exc)
resp = BadRequest("%s" % exc)
@@ -596,9 +595,19 @@ class SLO(Service):
return resp(self.environ, self.start_response)
resp = IDP.create_logout_response(msg, [binding])
+
+ if binding == BINDING_SOAP:
+ destination = ""
+ response = False
+ else:
+ binding, destination = IDP.pick_binding("single_logout_service",
+ [binding], "spsso",
+ req_info)
+ response = True
try:
- hinfo = IDP.apply_binding(binding, "%s" % resp, "", relay_state)
+ hinfo = IDP.apply_binding(binding, "%s" % resp, destination, relay_state,
+ response=response)
except Exception as exc:
logger.error("ServiceError: %s" % exc)
resp = ServiceError("%s" % exc)
@@ -609,8 +618,18 @@ class SLO(Service):
if delco:
hinfo["headers"].append(delco)
logger.info("Header: %s" % (hinfo["headers"],))
- resp = Response(hinfo["data"], headers=hinfo["headers"])
- return resp(self.environ, self.start_response)
+
+ if binding == BINDING_HTTP_REDIRECT:
+ for key, value in hinfo['headers']:
+ if key.lower() == 'location':
+ resp = Redirect(value, headers=hinfo["headers"])
+ return resp(self.environ, self.start_response)
+
+ resp = ServiceError('missing Location header')
+ return resp(self.environ, self.start_response)
+ else:
+ resp = Response(hinfo["data"], headers=hinfo["headers"])
+ return resp(self.environ, self.start_response)
# ----------------------------------------------------------------------------
# Manage Name ID service