URL: https://github.com/freeipa/freeipa/pull/206 Author: simo5 Title: #206: Properly handle multiple cookies in rpcclient Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/206/head:pr206 git checkout pr206
From df541c3c1bef0cfdfc0c6c412218eeb69ef0affd Mon Sep 17 00:00:00 2001 From: Simo Sorce <[email protected]> Date: Tue, 1 Nov 2016 14:59:12 -0400 Subject: [PATCH 1/2] Properly handle multiple cookies in rpcclient Signed-off-by: Simo Sorce <[email protected]> --- ipalib/rpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipalib/rpc.py b/ipalib/rpc.py index bd13251..dc63dc3 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -721,7 +721,7 @@ def store_session_cookie(self, cookie_header): pass def parse_response(self, response): - self.store_session_cookie(response.getheader('Set-Cookie')) + self.store_session_cookie(response.msg.getheaders('Set-Cookie')) return SSLTransport.parse_response(self, response) From 5fe6cac8e2a006d8c2b11fab6fd7a5dbeebdcce7 Mon Sep 17 00:00:00 2001 From: Simo Sorce <[email protected]> Date: Fri, 30 Sep 2016 16:17:31 -0400 Subject: [PATCH 2/2] Properly handle multiple cookies in rpc lib. Signed-off-by: Simo Sorce <[email protected]> --- ipalib/rpc.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ipalib/rpc.py b/ipalib/rpc.py index dc63dc3..bd25e6f 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -699,12 +699,20 @@ def store_session_cookie(self, cookie_header): principal = getattr(context, 'principal', None) request_url = getattr(context, 'request_url', None) - root_logger.debug("received Set-Cookie '%s'", cookie_header) + root_logger.debug("received Set-Cookie (%s)'%s'", type(cookie_header), + cookie_header) + + if not isinstance(cookie_header, list): + cookie_header = [cookie_header] # Search for the session cookie try: - session_cookie = Cookie.get_named_cookie_from_string(cookie_header, - COOKIE_NAME, request_url) + for cookie in cookie_header: + session_cookie = \ + Cookie.get_named_cookie_from_string(cookie, COOKIE_NAME, + request_url) + if session_cookie is not None: + break except Exception as e: root_logger.error("unable to parse cookie header '%s': %s", cookie_header, e) return
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
