Skip to content

Commit 27f8fbf

Browse files
authored
Merge pull request #463 from splunk/preserve_thirdparty_cookies
Preserve thirdparty cookies
2 parents 31cf507 + 9dbc86b commit 27f8fbf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

splunklib/binding.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,23 +526,27 @@ def _auth_headers(self):
526526
527527
:returns: A list of 2-tuples containing key and value
528528
"""
529+
header = []
529530
if self.has_cookies():
530531
return [("Cookie", _make_cookie_header(list(self.get_cookies().items())))]
531532
elif self.basic and (self.username and self.password):
532533
token = 'Basic %s' % b64encode(("%s:%s" % (self.username, self.password)).encode('utf-8')).decode('ascii')
533-
return [("Authorization", token)]
534534
elif self.bearerToken:
535535
token = 'Bearer %s' % self.bearerToken
536-
return [("Authorization", token)]
537536
elif self.token is _NoAuthenticationToken:
538-
return []
537+
token = []
539538
else:
540539
# Ensure the token is properly formatted
541540
if self.token.startswith('Splunk '):
542541
token = self.token
543542
else:
544543
token = 'Splunk %s' % self.token
545-
return [("Authorization", token)]
544+
if token:
545+
header.append(("Authorization", token))
546+
if self.get_cookies().__len__() > 0:
547+
header.append("Cookie", _make_cookie_header(self.get_cookies().items()))
548+
549+
return header
546550

547551
def connect(self):
548552
"""Returns an open connection (socket) to the Splunk instance.

0 commit comments

Comments
 (0)