diff options
author | Erick Tryzelaar <erickt@cloudera.com> | 2014-10-29 12:45:38 -0700 |
---|---|---|
committer | Erick Tryzelaar <erickt@cloudera.com> | 2014-11-03 14:23:05 -0800 |
commit | 5e8504c287183d7f91615ae2577e28ded32566cd (patch) | |
tree | baff6f1d574973af37466e2e1886147283001bae | |
parent | 1e0b34a401c6d3a0aa14661e5ae1a24e558c82c6 (diff) | |
download | pysaml2-5e8504c287183d7f91615ae2577e28ded32566cd.tar.gz |
Fix example/idp2 logging out with SOAP, POST, or REDIRECT
-rwxr-xr-x | example/idp2/idp.py | 31 |
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 |