Skip to content

Commit

Permalink
fix geti session proxies handling
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Davidyuk <igor.davidyuk@intel.com>
  • Loading branch information
igor-davidyuk committed Apr 22, 2024
1 parent c931572 commit 6302563
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions geti_sdk/http_session/geti_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(
if server_config.proxies is None:
self._proxies: Dict[str, str] = {}
else:
self._proxies = {"proxies": server_config.proxies}
self._proxies = server_config.proxies

# Configure certificate verification
if not server_config.has_valid_certificate:
Expand Down Expand Up @@ -149,7 +149,7 @@ def _get_initial_login_url(self) -> str:
"&scope=openid+profile+groups+email+offline_access"
)
url = f"{self.config.host}/dex/auth/regular_users?{params}"
response = self.get(url, allow_redirects=False, **self._proxies)
response = self.get(url, allow_redirects=False, proxies=self._proxies)
login_page_url = self._follow_login_redirects(response)
return login_page_url

Expand Down Expand Up @@ -194,7 +194,7 @@ def authenticate(self, verbose: bool = True):
cookies=cookies,
headers=headers,
allow_redirects=True,
**self._proxies,
proxies=self._proxies,
)
self._handle_dex_response(response)
if verbose:
Expand Down Expand Up @@ -275,7 +275,7 @@ def get_rest_response(
self.headers.pop("x-geti-csrf-protection", "")

try:
response = self.request(**request_params, **self._proxies)
response = self.request(**request_params, proxies=self._proxies)
except requests.exceptions.SSLError as error:
raise requests.exceptions.SSLError(
f"Connection to Intel® Geti™ server at '{self.config.host}' failed, "
Expand Down Expand Up @@ -333,7 +333,9 @@ def logout(self, verbose: bool = True) -> None:
+ "/oauth2/sign_out"
)
try:
response = self.request(url=sign_out_url, method="GET", **self._proxies)
response = self.request(
url=sign_out_url, method="GET", proxies=self._proxies
)

if response.status_code in SUCCESS_STATUS_CODES:
if verbose:
Expand Down Expand Up @@ -469,7 +471,7 @@ def _handle_error_response(
for file_name, file_buffer in request_params["files"].items():
file_buffer.seek(0, 0)

response = self.request(**request_params, **self._proxies)
response = self.request(**request_params, proxies=self._proxies)

if response.status_code in SUCCESS_STATUS_CODES:
return response
Expand Down Expand Up @@ -598,7 +600,7 @@ def _handle_dex_response(self, response: Response) -> None:
url=f"{self.config.host}/dex/token",
data=data,
allow_redirects=True,
**self._proxies,
proxies=self._proxies,
)
token = login_response.json().get("access_token", None)
self._cookies.update({GETI_COOKIE_NAME: token})

0 comments on commit 6302563

Please sign in to comment.