|
16 | 16 | from cachetools import LRUCache, cached
|
17 | 17 | from pydantic import ValidationError
|
18 | 18 | from requests import Session
|
| 19 | +from requests.cookies import RequestsCookieJar |
19 | 20 |
|
20 | 21 | from ark_sdk_python.args import ArkArgsFormatter, ArkInquirerRender
|
21 | 22 | from ark_sdk_python.auth.identity.ark_identity_fqdn_resolver import ArkIdentityFQDNResolver
|
@@ -73,7 +74,7 @@ def input_process(pipe_write: Connection, pipe_read: Connection, mechanism: Mech
|
73 | 74 |
|
74 | 75 |
|
75 | 76 | class ArkIdentity:
|
76 |
| - __LAST_START_AUTH_RESP: Dict[str, Tuple[StartAuthResponse, datetime]] = {} |
| 77 | + __LAST_START_AUTH_RESP: Dict[str, Tuple[StartAuthResponse, datetime, RequestsCookieJar]] = {} |
77 | 78 | __LAST_START_AUTH_RESP_DELTA_SECONDS: Final[int] = 30
|
78 | 79 |
|
79 | 80 | def __init__(
|
@@ -478,7 +479,11 @@ def is_password_required(cls, username: str, identity_url: Optional[str], identi
|
478 | 479 | identity_tenant_subdomain=identity_tenant_subdomain,
|
479 | 480 | )
|
480 | 481 | resp = identity.__start_authentication()
|
481 |
| - ArkIdentity.__LAST_START_AUTH_RESP[f'{identity.identity_url}_{username}'] = (resp, datetime.now()) |
| 482 | + ArkIdentity.__LAST_START_AUTH_RESP[f'{identity.identity_url}_{username}'] = ( |
| 483 | + resp, |
| 484 | + datetime.now(), |
| 485 | + identity.session.cookies, |
| 486 | + ) |
482 | 487 | return (
|
483 | 488 | resp.result.idp_redirect_url == None
|
484 | 489 | and resp.result.challenges
|
@@ -533,6 +538,7 @@ def auth_identity(self, profile: Optional[ArkProfile] = None, interactive: bool
|
533 | 538 | start_auth_response_time = ArkIdentity.__LAST_START_AUTH_RESP[f'{self.__identity_url}_{self.__username}']
|
534 | 539 | if (datetime.now() - start_auth_response_time[1]).total_seconds() < ArkIdentity.__LAST_START_AUTH_RESP_DELTA_SECONDS:
|
535 | 540 | start_auth_response = start_auth_response_time[0]
|
| 541 | + self.__session.cookies.update(start_auth_response_time[2]) |
536 | 542 | del ArkIdentity.__LAST_START_AUTH_RESP[f'{self.__identity_url}_{self.__username}']
|
537 | 543 | if not start_auth_response:
|
538 | 544 | start_auth_response = self.__start_authentication()
|
|
0 commit comments