Skip to content

Commit

Permalink
[Bug] Set session cookie key to sid (elastic#3010)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikaayenson authored Aug 22, 2023
1 parent 9482bda commit c72ec4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kibana/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def request(self, method, uri, params=None, data=None, error=True, verbose=True,
body = json.dumps(data)

response = self.session.request(method, url, params=params, data=body, **kwargs)

if response.status_code != 200:
# retry once
response = self.session.request(method, url, params=params, data=body, **kwargs)

if error:
try:
response.raise_for_status()
Expand Down Expand Up @@ -168,8 +173,9 @@ def login(self, kibana_username, kibana_password, provider_type=None, provider_n

def add_cookie(self, cookie):
"""Add cookie to be used for auth (such as from an SSO session)."""
# the request to /api/status will also add the cookie to the cookie jar upon a successful response
self.session.headers['cookie'] = cookie
# https://www.elastic.co/guide/en/kibana/7.10/security-settings-kb.html#security-session-and-cookie-settings
self.session.headers['sid'] = cookie
self.session.cookies.set('sid', cookie)
self.status = self.get('/api/status')
self.authenticated = True

Expand Down

0 comments on commit c72ec4d

Please sign in to comment.