Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions galaxykit/gw_auth_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,22 @@ def get_header_csfrtoken(self, session):
match = re.search(token_pattern, response.text)
return match.group(1)

def parse_custom_gateway_sessionid(self, cookies):
"""Support gateway_sessionid cookie with optional suffix.
For example the aap-dev 2.7, the HTTP header key is gateway_sessionid44927.
"""
for cookie in cookies:
if cookie.name.startswith("gateway_sessionid"):
return cookie.name, cookie.value
return None, None

def get_cookies_from_response(self, response):
self.csrftoken = response.cookies["csrftoken"]
gateway_sessionid = response.cookies["gateway_sessionid"]
custom_sessionid, gateway_sessionid = self.parse_custom_gateway_sessionid(
response.cookies
)
return {
"Accept": "application/json",
"Cookie": f"csrftoken={self.csrftoken}; gateway_sessionid={gateway_sessionid}",
"Cookie": f"csrftoken={self.csrftoken}; {custom_sessionid}={gateway_sessionid}",
"X-CSRFToken": self.csrftoken,
}
Loading