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 25f0224a76c1dd1942fcaef2b3a606ab21d6c805 Mon Sep 17 00:00:00 2001
From: Simo Sorce <s...@redhat.com>
Date: Tue, 1 Nov 2016 14:59:12 -0400
Subject: [PATCH 1/2] Properly handle multiple cookies in rpcclient

Signed-off-by: Simo Sorce <s...@redhat.com>
---
 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 0c6581b72d2af1bf45a88428b86e54d5dac4fc9e Mon Sep 17 00:00:00 2001
From: Simo Sorce <s...@redhat.com>
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 <s...@redhat.com>
---
 ipalib/rpc.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index dc63dc3..63ca87c 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -699,12 +699,19 @@ 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

Reply via email to