ark-sdk-python 2.1.2__py3-none-any.whl → 2.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ark_sdk_python/auth/identity/ark_identity.py +55 -12
- ark_sdk_python/common/ark_version.py +1 -1
- ark_sdk_python/models/common/identity/ark_identity_auth_schemas.py +15 -1
- {ark_sdk_python-2.1.2.dist-info → ark_sdk_python-2.1.3.dist-info}/METADATA +2 -2
- {ark_sdk_python-2.1.2.dist-info → ark_sdk_python-2.1.3.dist-info}/RECORD +9 -9
- {ark_sdk_python-2.1.2.dist-info → ark_sdk_python-2.1.3.dist-info}/LICENSE.txt +0 -0
- {ark_sdk_python-2.1.2.dist-info → ark_sdk_python-2.1.3.dist-info}/NOTICES.md +0 -0
- {ark_sdk_python-2.1.2.dist-info → ark_sdk_python-2.1.3.dist-info}/WHEEL +0 -0
- {ark_sdk_python-2.1.2.dist-info → ark_sdk_python-2.1.3.dist-info}/entry_points.txt +0 -0
|
@@ -92,11 +92,11 @@ class ArkIdentity:
|
|
|
92
92
|
) -> None:
|
|
93
93
|
self.__username = username
|
|
94
94
|
self.__password = password
|
|
95
|
+
self.__logger = logger or get_logger(app=self.__class__.__name__)
|
|
95
96
|
self.__identity_url = self.__resolve_fqdn_from_username_or_subdomain(identity_url, identity_tenant_subdomain)
|
|
96
97
|
if not self.__identity_url.startswith('https://'):
|
|
97
98
|
self.__identity_url = f'https://{self.__identity_url}'
|
|
98
99
|
self.__mfa_type = mfa_type or 'email'
|
|
99
|
-
self.__logger = logger or get_logger(app=self.__class__.__name__)
|
|
100
100
|
self.__interaction_process: Optional[Process] = None
|
|
101
101
|
self.__is_polling: bool = False
|
|
102
102
|
self.__keyring = ArkKeyring(self.__class__.__name__.lower()) if cache_authentication else None
|
|
@@ -204,17 +204,20 @@ class ArkIdentity:
|
|
|
204
204
|
return parsed_res
|
|
205
205
|
|
|
206
206
|
def __advance_authentication(
|
|
207
|
-
self, mechanism_id: str, session_id: str, answer: str, action: str
|
|
208
|
-
) -> Union[AdvanceAuthMidResponse, AdvanceAuthResponse]:
|
|
207
|
+
self, mechanism_id: str, session_id: str, answer: str, action: str, is_idp_auth: bool = False
|
|
208
|
+
) -> Union[AdvanceAuthMidResponse, AdvanceAuthResponse, IdpAuthStatusResponse]:
|
|
209
209
|
self.__logger.info(f'Advancing authentication with user {self.__username} and fqdn {self.__identity_url} and action {action}')
|
|
210
210
|
response = self.__session.post(
|
|
211
211
|
url=f'{self.__identity_url}/Security/AdvanceAuthentication',
|
|
212
212
|
json={'SessionId': session_id, 'MechanismId': mechanism_id, 'Action': action, 'Answer': answer},
|
|
213
213
|
)
|
|
214
214
|
try:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
if is_idp_auth:
|
|
216
|
+
parsed_res: IdpAuthStatusResponse = IdpAuthStatusResponse.model_validate_json(response.text)
|
|
217
|
+
else:
|
|
218
|
+
parsed_res: AdvanceAuthMidResponse = AdvanceAuthMidResponse.model_validate_json(response.text)
|
|
219
|
+
if parsed_res.result.summary == 'LoginSuccess':
|
|
220
|
+
parsed_res: AdvanceAuthResponse = AdvanceAuthResponse.model_validate_json(response.text)
|
|
218
221
|
except (ValidationError, TypeError) as ex:
|
|
219
222
|
raise ArkException(f'Identity advance authentication failed to be parsed / validated [{response.text}]') from ex
|
|
220
223
|
return parsed_res
|
|
@@ -281,14 +284,16 @@ class ArkIdentity:
|
|
|
281
284
|
if output_conn.poll():
|
|
282
285
|
mfa_code = output_conn.recv()
|
|
283
286
|
advance_resp = self.__advance_authentication(
|
|
284
|
-
mechanism.mechanism_id, start_auth_response.result.session_id, mfa_code, 'Answer'
|
|
287
|
+
mechanism.mechanism_id, start_auth_response.result.session_id, mfa_code, 'Answer', False
|
|
285
288
|
)
|
|
286
289
|
if isinstance(advance_resp, AdvanceAuthResponse):
|
|
287
290
|
input_conn.send('DONE')
|
|
288
291
|
else:
|
|
289
292
|
input_conn.send('CONTINUE')
|
|
290
293
|
else:
|
|
291
|
-
advance_resp = self.__advance_authentication(
|
|
294
|
+
advance_resp = self.__advance_authentication(
|
|
295
|
+
mechanism.mechanism_id, start_auth_response.result.session_id, '', 'Poll', False
|
|
296
|
+
)
|
|
292
297
|
if isinstance(advance_resp, AdvanceAuthResponse):
|
|
293
298
|
# Done here, save the token
|
|
294
299
|
self.__is_polling = False
|
|
@@ -340,6 +345,37 @@ class ArkIdentity:
|
|
|
340
345
|
self.__mfa_type = next(filter(lambda f: factors[f] == answers['mfa'], factors.keys()))
|
|
341
346
|
return next(filter(lambda m: factors[m.name.lower()] == answers['mfa'], supported_mechanisms))
|
|
342
347
|
|
|
348
|
+
def __perform_pin_code_idp_authentication(
|
|
349
|
+
self, start_auth_response: StartAuthResponse, profile: Optional[ArkProfile] = None, interactive: bool = False
|
|
350
|
+
) -> None:
|
|
351
|
+
if not interactive:
|
|
352
|
+
raise ArkException('Non-interactive mode is not supported for OOB PIN code authentication')
|
|
353
|
+
answers = inquirer.prompt(
|
|
354
|
+
[inquirer.Password('answer', message='Please enter the PIN code displayed after you logged in to your identity provider')],
|
|
355
|
+
render=ArkInquirerRender(),
|
|
356
|
+
)
|
|
357
|
+
if not answers:
|
|
358
|
+
raise ArkAuthException('Canceled by user')
|
|
359
|
+
pin_code = answers['answer']
|
|
360
|
+
result = self.__advance_authentication('OOBAUTHPIN', start_auth_response.result.idp_login_session_id, pin_code, 'Answer', True)
|
|
361
|
+
if (
|
|
362
|
+
not result
|
|
363
|
+
or not result.success
|
|
364
|
+
or not isinstance(result, IdpAuthStatusResponse)
|
|
365
|
+
or not result.result.summary
|
|
366
|
+
or result.result.summary != 'LoginSuccess'
|
|
367
|
+
or not result.result.token
|
|
368
|
+
):
|
|
369
|
+
raise ArkAuthException('Failed to perform idp authentication with OOB PIN')
|
|
370
|
+
# We managed to successfully authenticate
|
|
371
|
+
# Done here, save the token
|
|
372
|
+
self.__session_details = result.result
|
|
373
|
+
self.__session.headers.update({'Authorization': f'Bearer {result.result.token}', **ArkIdentityFQDNResolver.default_headers()})
|
|
374
|
+
delta = self.__session_details.token_lifetime or DEFAULT_TOKEN_LIFETIME_SECONDS
|
|
375
|
+
self.__session_exp = datetime.now() + timedelta(seconds=delta)
|
|
376
|
+
if self.__cache_authentication:
|
|
377
|
+
self.__save_cache(profile)
|
|
378
|
+
|
|
343
379
|
def __perform_idp_authentication(
|
|
344
380
|
self, start_auth_response: StartAuthResponse, profile: Optional[ArkProfile] = None, interactive: bool = False
|
|
345
381
|
) -> None:
|
|
@@ -356,6 +392,11 @@ class ArkIdentity:
|
|
|
356
392
|
# Error can be ignored
|
|
357
393
|
webbrowser.open(start_auth_response.result.idp_redirect_short_url, new=0, autoraise=True)
|
|
358
394
|
|
|
395
|
+
# Pin code flow
|
|
396
|
+
if start_auth_response.result.idp_oob_auth_pin_required:
|
|
397
|
+
self.__perform_pin_code_idp_authentication(start_auth_response, profile, interactive)
|
|
398
|
+
return
|
|
399
|
+
|
|
359
400
|
# Start polling for idp auth
|
|
360
401
|
self.__is_polling = True
|
|
361
402
|
start_time = datetime.now()
|
|
@@ -400,7 +441,7 @@ class ArkIdentity:
|
|
|
400
441
|
raise ArkAuthException('Canceled by user')
|
|
401
442
|
self.__password = answers['answer']
|
|
402
443
|
advance_resp = self.__advance_authentication(
|
|
403
|
-
mechanism.mechanism_id, start_auth_response.result.session_id, self.__password, 'Answer'
|
|
444
|
+
mechanism.mechanism_id, start_auth_response.result.session_id, self.__password, 'Answer', False
|
|
404
445
|
)
|
|
405
446
|
if isinstance(advance_resp, AdvanceAuthResponse) and len(start_auth_response.result.challenges) == 1:
|
|
406
447
|
# Done here, save the token
|
|
@@ -568,7 +609,7 @@ class ArkIdentity:
|
|
|
568
609
|
return
|
|
569
610
|
else:
|
|
570
611
|
oob_advance_resp = self.__advance_authentication(
|
|
571
|
-
mechanism.mechanism_id, start_auth_response.result.session_id, '', 'StartOOB'
|
|
612
|
+
mechanism.mechanism_id, start_auth_response.result.session_id, '', 'StartOOB', False
|
|
572
613
|
)
|
|
573
614
|
self.__poll_authentication(profile, mechanism, start_auth_response, oob_advance_resp, interactive)
|
|
574
615
|
if self.__session_details:
|
|
@@ -591,7 +632,7 @@ class ArkIdentity:
|
|
|
591
632
|
for mechanism in start_auth_response.result.challenges[current_challenge_idx].mechanisms:
|
|
592
633
|
if mechanism.name.lower() == self.__mfa_type.lower():
|
|
593
634
|
oob_advance_resp = self.__advance_authentication(
|
|
594
|
-
mechanism.mechanism_id, start_auth_response.result.session_id, '', 'StartOOB'
|
|
635
|
+
mechanism.mechanism_id, start_auth_response.result.session_id, '', 'StartOOB', False
|
|
595
636
|
)
|
|
596
637
|
self.__poll_authentication(profile, mechanism, start_auth_response, oob_advance_resp, interactive)
|
|
597
638
|
return
|
|
@@ -602,7 +643,9 @@ class ArkIdentity:
|
|
|
602
643
|
# Handle the rest of the challenges, might also handle the first challenge if no password is in the mechanisms
|
|
603
644
|
for challenge in start_auth_response.result.challenges[current_challenge_idx:]:
|
|
604
645
|
mechanism = self.__pick_mechanism(challenge)
|
|
605
|
-
oob_advance_resp = self.__advance_authentication(
|
|
646
|
+
oob_advance_resp = self.__advance_authentication(
|
|
647
|
+
mechanism.mechanism_id, start_auth_response.result.session_id, '', 'StartOOB', False
|
|
648
|
+
)
|
|
606
649
|
self.__poll_authentication(profile, mechanism, start_auth_response, oob_advance_resp, interactive)
|
|
607
650
|
|
|
608
651
|
# pylint: disable=unused-argument
|
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '2.1.
|
|
1
|
+
__version__ = '2.1.3'
|
|
@@ -49,14 +49,28 @@ class StartAuthResult(ArkModel):
|
|
|
49
49
|
idp_login_session_id: Optional[str] = Field(default=None, alias='IdpLoginSessionId')
|
|
50
50
|
idp_redirect_short_url: Optional[str] = Field(default=None, alias='IdpRedirectShortUrl')
|
|
51
51
|
idp_short_url_id: Optional[str] = Field(default=None, alias='IdpShortUrlId')
|
|
52
|
+
idp_oob_auth_pin_required: Optional[bool] = Field(default=None, alias='IdpOobAuthPinRequired')
|
|
52
53
|
tenant_id: Optional[str] = Field(default=None, alias='TenantId')
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
class IdpAuthStatusResult(ArkModel):
|
|
56
|
-
|
|
57
|
+
auth_level: Optional[str] = Field(default=None, alias='AuthLevel')
|
|
58
|
+
display_name: Optional[str] = Field(default=None, alias='DisplayName')
|
|
59
|
+
auth: Optional[str] = Field(default=None, alias='Auth')
|
|
60
|
+
user_id: Optional[str] = Field(default=None, alias='UserId')
|
|
61
|
+
state: Optional[str] = Field(default=None, alias='State')
|
|
57
62
|
token_lifetime: Optional[int] = Field(default=None, alias='TokenLifetime')
|
|
58
63
|
token: Optional[str] = Field(default=None, alias='Token')
|
|
59
64
|
refresh_token: Optional[str] = Field(default=None, alias='RefreshToken')
|
|
65
|
+
email_address: Optional[str] = Field(default=None, alias='EmailAddress')
|
|
66
|
+
user_directory: Optional[str] = Field(default=None, alias='UserDirectory')
|
|
67
|
+
pod_fqdn: Optional[str] = Field(default=None, alias='PodFqdn')
|
|
68
|
+
user: Optional[str] = Field(default=None, alias='User')
|
|
69
|
+
customer_id: Optional[str] = Field(default=None, alias='CustomerID')
|
|
70
|
+
forest: Optional[str] = Field(default=None, alias='Forest')
|
|
71
|
+
system_id: Optional[str] = Field(default=None, alias='SystemID')
|
|
72
|
+
source_ds_type: Optional[str] = Field(default=None, alias='SourceDsType')
|
|
73
|
+
summary: Optional[str] = Field(default=None, alias='Summary')
|
|
60
74
|
|
|
61
75
|
|
|
62
76
|
class TenantFqdnResponse(IdentityApiResponse):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: ark-sdk-python
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.3
|
|
4
4
|
Summary: Official Ark SDK / CLI for CyberArk Identity Security Platform
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: CyberArk
|
|
@@ -18,7 +18,7 @@ Requires-Dist: aenum
|
|
|
18
18
|
Requires-Dist: argcomplete
|
|
19
19
|
Requires-Dist: cachetools
|
|
20
20
|
Requires-Dist: colorama
|
|
21
|
-
Requires-Dist: deepdiff (==
|
|
21
|
+
Requires-Dist: deepdiff (==8.*)
|
|
22
22
|
Requires-Dist: dill
|
|
23
23
|
Requires-Dist: fake-useragent (==1.5.1)
|
|
24
24
|
Requires-Dist: inquirer
|
|
@@ -16,7 +16,7 @@ ark_sdk_python/auth/__init__.py,sha256=1l29Rf3VhwmV8z3YROiQVcgrZYSeeCqVN4zna77tn
|
|
|
16
16
|
ark_sdk_python/auth/ark_auth.py,sha256=2fPlABM3AwWmb1h0lQPQAz93u1ZluYKv7axlfg4lq5Q,12988
|
|
17
17
|
ark_sdk_python/auth/ark_isp_auth.py,sha256=i8GIA5ldsT7loJSG898-XQQyg84M-1CJ0aUZa1zcLSc,9689
|
|
18
18
|
ark_sdk_python/auth/identity/__init__.py,sha256=2Yyc_Rrx-D4PsSdg-ESl5pFFTpqu6LUPSc4ZW59oOP8,328
|
|
19
|
-
ark_sdk_python/auth/identity/ark_identity.py,sha256=
|
|
19
|
+
ark_sdk_python/auth/identity/ark_identity.py,sha256=Shf4VL7ZVpwstrEaIqbN716PEMw6kKEagqa6GSi-bAc,34482
|
|
20
20
|
ark_sdk_python/auth/identity/ark_identity_fqdn_resolver.py,sha256=a2FA8CA4DkVHsiOw_NwTZ-TmE3s19l-kPUoO57nowYc,4715
|
|
21
21
|
ark_sdk_python/auth/identity/ark_identity_service_user.py,sha256=pspgsG3dg5PE0XueVParz3CshTdtQJFLdsoMzrx2wfA,7901
|
|
22
22
|
ark_sdk_python/cli_services/__init__.py,sha256=e9vdwqNiYqhZmK05Wgpz-Hf9SycK_3X-RS3CK9n2lIs,87
|
|
@@ -42,7 +42,7 @@ ark_sdk_python/common/ark_random_utils.py,sha256=dmPsvF9lTg90SdrYENmVD6giQdZlb5y
|
|
|
42
42
|
ark_sdk_python/common/ark_retry.py,sha256=fWkKYLIK2z5U14NFzhqUP_o0VkSG9F9EiZIhdfa_EYY,1815
|
|
43
43
|
ark_sdk_python/common/ark_system_config.py,sha256=cl44cYSgXZEnoRYu048aBeJwWRPdCT_flC3hTWyytX4,2436
|
|
44
44
|
ark_sdk_python/common/ark_user_agent.py,sha256=76v92ulwh_AlfBN1cz5BYkYUzPDfEsQchRXKBG4BTrw,213
|
|
45
|
-
ark_sdk_python/common/ark_version.py,sha256=
|
|
45
|
+
ark_sdk_python/common/ark_version.py,sha256=hgD1miBO_f3fboq1GKyV4DdK_igCLGJFnZRD7l9oNRs,22
|
|
46
46
|
ark_sdk_python/common/connections/__init__.py,sha256=RyARha6jTeaUw1cIGBSR7nOYxCV3fC24juKb-17yXLw,104
|
|
47
47
|
ark_sdk_python/common/connections/ark_connection.py,sha256=wjYpn_9EJ-B679006VqQREFeTOhINmw-heiRqlpuCnY,1613
|
|
48
48
|
ark_sdk_python/common/connections/ssh/__init__.py,sha256=Ycv3BDI2iw-N7BdRkpAv2Qi90O4bp8sPyNsJnuQLfWo,256
|
|
@@ -132,7 +132,7 @@ ark_sdk_python/models/common/connections/connection_data/__init__.py,sha256=_zey
|
|
|
132
132
|
ark_sdk_python/models/common/connections/connection_data/ark_ssh_connection_data.py,sha256=41yOuJhRrpJf2T8xg6yuhOwo1eZ1WqNi3Aex1dgE5J8,92
|
|
133
133
|
ark_sdk_python/models/common/connections/connection_data/ark_winrm_connection_data.py,sha256=gH2mEk0NSHsPwpt7NgNIxQQODQq5DSZ_kgW9WrEOS4U,254
|
|
134
134
|
ark_sdk_python/models/common/identity/__init__.py,sha256=E-WPD6ZxroVZ4HOrQJdjWrrJYZ-XGBOsjO525DEniHA,1945
|
|
135
|
-
ark_sdk_python/models/common/identity/ark_identity_auth_schemas.py,sha256=
|
|
135
|
+
ark_sdk_python/models/common/identity/ark_identity_auth_schemas.py,sha256=zv890mNMURdN7FuIHMJARpt_gTu7sCYxBsypoC03Pn4,4920
|
|
136
136
|
ark_sdk_python/models/common/identity/ark_identity_common_schemas.py,sha256=nhlP-Wa08u_NKRiYdrl4E4fQpIECj6BocXdNfQlgmW8,498
|
|
137
137
|
ark_sdk_python/models/common/identity/ark_identity_directory_schemas.py,sha256=DYM0TigGIqt_ZSyhA-ikN1uDQLkn1WZwZO2Bi6XnUJY,5137
|
|
138
138
|
ark_sdk_python/models/common/isp/__init__.py,sha256=QSvRKyNiBSpzZggBk4p3TzH5YcGF-M5uu08hK2msPBk,141
|
|
@@ -577,9 +577,9 @@ ark_sdk_python/services/uap/sia/db/__init__.py,sha256=wnRWgugupaIX-47EkyIplpr17w
|
|
|
577
577
|
ark_sdk_python/services/uap/sia/db/ark_uap_sia_db_service.py,sha256=cgRFTtwaPssNiF_PmGx3nD1ywSsuxE5kJs5K5xKh3Z4,4017
|
|
578
578
|
ark_sdk_python/services/uap/sia/vm/__init__.py,sha256=-vorR4le7AbvkMIUAdaEDQ774mlFT_Ye_FWqPlwX-C0,123
|
|
579
579
|
ark_sdk_python/services/uap/sia/vm/ark_uap_sia_vm_service.py,sha256=sF0B-fo-LXUlHXMfZbggmdUH5gkjeGAPau8MZ_bBfkU,4015
|
|
580
|
-
ark_sdk_python-2.1.
|
|
581
|
-
ark_sdk_python-2.1.
|
|
582
|
-
ark_sdk_python-2.1.
|
|
583
|
-
ark_sdk_python-2.1.
|
|
584
|
-
ark_sdk_python-2.1.
|
|
585
|
-
ark_sdk_python-2.1.
|
|
580
|
+
ark_sdk_python-2.1.3.dist-info/LICENSE.txt,sha256=d4EzYx2apA3-GqrFY23wLtc6UmQNXG05gyLfZ3oWVRs,11358
|
|
581
|
+
ark_sdk_python-2.1.3.dist-info/METADATA,sha256=tWORiUUkNUXKXYfndxalVL7TlqkTzzVogh_7q0QgSwc,22039
|
|
582
|
+
ark_sdk_python-2.1.3.dist-info/NOTICES.md,sha256=vRzFZEsfBw5q3H1_cgZV50AVhNTqF8Smz9fSvn49Y1E,125803
|
|
583
|
+
ark_sdk_python-2.1.3.dist-info/WHEEL,sha256=0IJoS5KyK2sZuSvGyrwXyRwSVwTkTkpEcRzz5xcYUMQ,110
|
|
584
|
+
ark_sdk_python-2.1.3.dist-info/entry_points.txt,sha256=v5bcuRn8w42ZKQspfvX3AliKmLVO6f7Zb_bma77p3vQ,47
|
|
585
|
+
ark_sdk_python-2.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|