pybritive 2.2.3__tar.gz → 2.3.0__tar.gz
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.
- {pybritive-2.2.3/src/pybritive.egg-info → pybritive-2.3.0}/PKG-INFO +1 -1
- pybritive-2.3.0/src/pybritive/__init__.py +1 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/britive_cli.py +54 -42
- pybritive-2.3.0/src/pybritive/commands/ls.py +79 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/aws_credential_process.py +1 -1
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/credentials.py +10 -4
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/encryption.py +9 -2
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/k8s_exec.py +7 -1
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/britive_options.py +29 -27
- pybritive-2.3.0/src/pybritive/options/search_text.py +8 -0
- {pybritive-2.2.3 → pybritive-2.3.0/src/pybritive.egg-info}/PKG-INFO +1 -1
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive.egg-info/SOURCES.txt +1 -0
- pybritive-2.2.3/src/pybritive/__init__.py +0 -1
- pybritive-2.2.3/src/pybritive/commands/ls.py +0 -58
- {pybritive-2.2.3 → pybritive-2.3.0}/LICENSE +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/README.md +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/pyproject.toml +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/setup.cfg +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/__init__.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/backend.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/browser.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/mode.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/output_format.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/profile_type.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/ssh_key_source.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/choices/ssh_push_public_key.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/cli_interface.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/__init__.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/api.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/aws.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/cache.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/checkin.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/checkout.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/clear.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/configure.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/login.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/logout.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/request.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/secret.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/ssh.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/commands/user.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/completers/__init__.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/completers/api.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/completers/api_command.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/completers/bash_gte_42.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/completers/powershell_completion.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/completers/profile.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/__init__.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/api_method_argument_decorator.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/build_britive.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/cache.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/cloud_credential_printer.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/config.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/k8s_exec_credential_builder.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/kube_config_builder.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/profile_argument_decorator.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/helpers/split.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/__init__.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/alias.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/aws_console_duration.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/aws_credentials_file.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/aws_profile.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/blocktime.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/browser.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/checked_out.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/configure_alias.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/configure_backend.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/configure_prompt.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/configure_tenant.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/console.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/extend.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/federation_provider.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/file.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/force_renew.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/gcloud_key_file.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/justification.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/maxpolltime.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/mode.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/otp.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/output_format.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/passphrase.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/profile_type.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/query.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/silent.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ssh_hostname.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ssh_key_source.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ssh_port.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ssh_push_public_key.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ssh_username.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/tenant.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ticket_id.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/ticket_type.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/token.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/verbose.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive/options/version.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive.egg-info/dependency_links.txt +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive.egg-info/entry_points.txt +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive.egg-info/requires.txt +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/src/pybritive.egg-info/top_level.txt +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0100_version.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0200_configure.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0300_login.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0400_ls.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0500_api.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0600_secret.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0700_cache.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0800_checkout.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_0900_checkin.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_1000_clear.py +0 -0
- {pybritive-2.2.3 → pybritive-2.3.0}/tests/test_1100_logout.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.3.0'
|
|
@@ -314,9 +314,9 @@ class BritiveCli:
|
|
|
314
314
|
output += f' (alias: {alias})'
|
|
315
315
|
self.print(output, ignore_silent=True)
|
|
316
316
|
|
|
317
|
-
def list_secrets(self):
|
|
317
|
+
def list_secrets(self, search_text: Optional[str] = None):
|
|
318
318
|
self.login()
|
|
319
|
-
self.print(self.b.my_secrets.list(), ignore_silent=True)
|
|
319
|
+
self.print(self.b.my_secrets.list(search=search_text), ignore_silent=True)
|
|
320
320
|
|
|
321
321
|
def list_approvals(self):
|
|
322
322
|
self.login()
|
|
@@ -338,14 +338,34 @@ class BritiveCli:
|
|
|
338
338
|
approvals.reverse()
|
|
339
339
|
self.print(approvals, ignore_silent=True)
|
|
340
340
|
|
|
341
|
-
def
|
|
341
|
+
def list_requests(self):
|
|
342
|
+
self.login()
|
|
343
|
+
requests = []
|
|
344
|
+
for request in self.b.my_requests.list():
|
|
345
|
+
request.pop('resource', None)
|
|
346
|
+
request.pop('consumer', None)
|
|
347
|
+
request.pop('timeToApprove', None)
|
|
348
|
+
request.pop('validFor', None)
|
|
349
|
+
request.pop('action', None)
|
|
350
|
+
request.pop('approvers', None)
|
|
351
|
+
request.pop('expirationTimeApproval', None)
|
|
352
|
+
request.pop('updatedAt', None)
|
|
353
|
+
request.pop('actionBy', None)
|
|
354
|
+
request.pop('validForInDays', None)
|
|
355
|
+
requests.append(request)
|
|
356
|
+
|
|
357
|
+
requests = sorted(requests, key=lambda x: x['createdAt'])
|
|
358
|
+
requests.reverse()
|
|
359
|
+
self.print(requests, ignore_silent=True)
|
|
360
|
+
|
|
361
|
+
def list_resources(self, search_text: Optional[str] = None):
|
|
342
362
|
self.login()
|
|
343
363
|
found_resource_names = []
|
|
344
364
|
resources = []
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
profiles =
|
|
365
|
+
resource_limit = int(self.config.my_resources_retrieval_limit)
|
|
366
|
+
profiles = self.b.my_resources.list(search_text=search_text, size=resource_limit)
|
|
367
|
+
if resource_limit:
|
|
368
|
+
profiles = profiles['data']
|
|
349
369
|
for item in profiles:
|
|
350
370
|
name = item['resourceName']
|
|
351
371
|
if name not in found_resource_names:
|
|
@@ -360,9 +380,14 @@ class BritiveCli:
|
|
|
360
380
|
found_resource_names.append(name)
|
|
361
381
|
self.print(resources, ignore_silent=True)
|
|
362
382
|
|
|
363
|
-
def list_profiles(
|
|
383
|
+
def list_profiles(
|
|
384
|
+
self,
|
|
385
|
+
checked_out: bool = False,
|
|
386
|
+
profile_type: Optional[str] = None,
|
|
387
|
+
search_text: Optional[str] = None,
|
|
388
|
+
):
|
|
364
389
|
self.login()
|
|
365
|
-
self._set_available_profiles(profile_type=profile_type)
|
|
390
|
+
self._set_available_profiles(profile_type=profile_type, search_text=search_text)
|
|
366
391
|
data = []
|
|
367
392
|
checked_out_profiles = {}
|
|
368
393
|
if checked_out: # only make this call if we have to
|
|
@@ -390,7 +415,7 @@ class BritiveCli:
|
|
|
390
415
|
'Application': profile['app_name'] or 'Resources',
|
|
391
416
|
'Environment': profile['env_name'],
|
|
392
417
|
'Profile': profile['profile_name'],
|
|
393
|
-
'Description': profile['profile_description']
|
|
418
|
+
'Description': profile['profile_description'] if profile['app_name'] else 'Resource',
|
|
394
419
|
'Type': profile['app_type'],
|
|
395
420
|
}
|
|
396
421
|
|
|
@@ -427,9 +452,9 @@ class BritiveCli:
|
|
|
427
452
|
if self.output_format == 'list-profiles':
|
|
428
453
|
self.output_format = 'list'
|
|
429
454
|
|
|
430
|
-
def list_applications(self):
|
|
455
|
+
def list_applications(self, search_text: Optional[str] = None):
|
|
431
456
|
self.login()
|
|
432
|
-
self._set_available_profiles()
|
|
457
|
+
self._set_available_profiles(profile_type='my-access', search_text=search_text)
|
|
433
458
|
keys = ['app_name', 'app_type', 'app_description']
|
|
434
459
|
apps = []
|
|
435
460
|
for profile in self.available_profiles:
|
|
@@ -440,14 +465,14 @@ class BritiveCli:
|
|
|
440
465
|
row = {
|
|
441
466
|
'Application': app['app_name'],
|
|
442
467
|
'Type': app['app_type'],
|
|
443
|
-
'Description': app['app_description'],
|
|
468
|
+
'Description': app['app_description'] or '',
|
|
444
469
|
}
|
|
445
470
|
data.append(row)
|
|
446
471
|
self.print(data, ignore_silent=True)
|
|
447
472
|
|
|
448
|
-
def list_environments(self):
|
|
473
|
+
def list_environments(self, search_text: Optional[str] = None):
|
|
449
474
|
self.login()
|
|
450
|
-
self._set_available_profiles()
|
|
475
|
+
self._set_available_profiles(profile_type='my-access', search_text=search_text)
|
|
451
476
|
envs = []
|
|
452
477
|
keys = ['app_name', 'app_type', 'env_name', 'env_description']
|
|
453
478
|
for profile in self.available_profiles:
|
|
@@ -459,37 +484,27 @@ class BritiveCli:
|
|
|
459
484
|
row = {
|
|
460
485
|
'Application': env['app_name'],
|
|
461
486
|
'Environment': env['env_name'],
|
|
462
|
-
'Description': env['env_description'],
|
|
487
|
+
'Description': env['env_description'] or '',
|
|
463
488
|
'Type': env['app_type'],
|
|
464
489
|
}
|
|
465
490
|
data.append(row)
|
|
466
491
|
self.print(data, ignore_silent=True)
|
|
467
492
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
profile['sessionAttributes']
|
|
475
|
-
for app in self.listed_profiles
|
|
476
|
-
if app['appContainerId'] == app_id
|
|
477
|
-
for profile in app.get('profiles', [])
|
|
478
|
-
if profile['profileId'] == profile_id
|
|
479
|
-
),
|
|
480
|
-
[],
|
|
481
|
-
)
|
|
482
|
-
|
|
483
|
-
def _set_available_profiles(self, from_cache_command=False, profile_type: Optional[str] = None):
|
|
493
|
+
def _set_available_profiles(
|
|
494
|
+
self,
|
|
495
|
+
from_cache_command=False,
|
|
496
|
+
profile_type: Optional[str] = None,
|
|
497
|
+
search_text: Optional[str] = None,
|
|
498
|
+
):
|
|
484
499
|
if not self.available_profiles:
|
|
485
500
|
data = []
|
|
486
501
|
if not profile_type or profile_type == 'my-access':
|
|
487
502
|
self.listed_profiles = None
|
|
488
503
|
access_limit = int(self.config.my_access_retrieval_limit)
|
|
489
504
|
increase = 0
|
|
490
|
-
while (access_data := self.b.my_access.list(size=access_limit + increase))[
|
|
491
|
-
|
|
492
|
-
) and len({a['papId'] for a in access_data['accesses']}) < access_limit:
|
|
505
|
+
while (access_data := self.b.my_access.list(search_text=search_text, size=access_limit + increase))[
|
|
506
|
+
'count'
|
|
507
|
+
] > len(access_data['accesses']) and len({a['papId'] for a in access_data['accesses']}) < access_limit:
|
|
493
508
|
increase += max(25, round(access_data['count'] * 0.25))
|
|
494
509
|
apps = {a['appContainerId']: a for a in access_data.get('apps', [])}
|
|
495
510
|
envs = {e['environmentId']: e for e in access_data.get('environments', [])}
|
|
@@ -518,18 +533,15 @@ class BritiveCli:
|
|
|
518
533
|
'profile_description': profile['papDescription'],
|
|
519
534
|
'profile_id': profile_id,
|
|
520
535
|
'profile_name': profile['papName'],
|
|
521
|
-
'session_attributes': profile
|
|
522
|
-
'sessionAttributes', self._get_missing_session_attributes(app_id, profile_id)
|
|
523
|
-
),
|
|
536
|
+
'session_attributes': profile['sessionAttributes'],
|
|
524
537
|
}
|
|
525
538
|
if row not in access_output:
|
|
526
539
|
access_output.append(row)
|
|
527
540
|
data += access_output[:access_limit] if access_limit else access_output
|
|
528
541
|
if self.b.feature_flags.get('server-access') and (not profile_type or profile_type == 'my-resources'):
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
profiles = self.b.my_resources.list(size=resource_limit)
|
|
542
|
+
resource_limit = int(self.config.my_resources_retrieval_limit)
|
|
543
|
+
profiles = self.b.my_resources.list(search_text=search_text, size=resource_limit)
|
|
544
|
+
if resource_limit:
|
|
533
545
|
profiles = profiles['data']
|
|
534
546
|
for item in profiles:
|
|
535
547
|
row = {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from pybritive.helpers.build_britive import build_britive
|
|
4
|
+
from pybritive.options.britive_options import britive_options
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@click.group()
|
|
8
|
+
def ls():
|
|
9
|
+
"""List resources available for currently authenticated identity."""
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@ls.command()
|
|
14
|
+
@build_britive
|
|
15
|
+
@britive_options(names='search_text,format,tenant,token,silent,passphrase,federation_provider')
|
|
16
|
+
def applications(ctx, search_text, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
17
|
+
"""List applications for the currently authenticated identity."""
|
|
18
|
+
ctx.obj.britive.list_applications(search_text=search_text)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@ls.command()
|
|
22
|
+
@build_britive
|
|
23
|
+
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
24
|
+
def approvals(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
25
|
+
"""List approvals for the currently authenticated identity."""
|
|
26
|
+
ctx.obj.britive.list_approvals()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@ls.command()
|
|
30
|
+
@build_britive
|
|
31
|
+
@britive_options(names='search_text,format,tenant,token,silent,passphrase,federation_provider')
|
|
32
|
+
def environments(ctx, search_text, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
33
|
+
"""List environments for the currently authenticated identity."""
|
|
34
|
+
ctx.obj.britive.list_environments(search_text=search_text)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@ls.command()
|
|
38
|
+
@build_britive
|
|
39
|
+
@britive_options(
|
|
40
|
+
names='checked_out,profile_type,search_text,output_format,tenant,token,silent,passphrase,federation_provider'
|
|
41
|
+
)
|
|
42
|
+
def profiles(
|
|
43
|
+
ctx,
|
|
44
|
+
checked_out,
|
|
45
|
+
profile_type,
|
|
46
|
+
search_text,
|
|
47
|
+
output_format,
|
|
48
|
+
tenant,
|
|
49
|
+
token,
|
|
50
|
+
silent,
|
|
51
|
+
passphrase,
|
|
52
|
+
federation_provider,
|
|
53
|
+
):
|
|
54
|
+
"""List profiles for the currently authenticated identity."""
|
|
55
|
+
ctx.obj.britive.list_profiles(checked_out=checked_out, profile_type=profile_type, search_text=search_text)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@ls.command()
|
|
59
|
+
@build_britive
|
|
60
|
+
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
61
|
+
def requests(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
62
|
+
"""List requests for the currently authenticated identity."""
|
|
63
|
+
ctx.obj.britive.list_requests()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@ls.command()
|
|
67
|
+
@build_britive
|
|
68
|
+
@britive_options(names='search_text,format,tenant,token,silent,passphrase,federation_provider')
|
|
69
|
+
def resources(ctx, search_text, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
70
|
+
"""List resources for the currently authenticated identity."""
|
|
71
|
+
ctx.obj.britive.list_resources(search_text=search_text)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@ls.command()
|
|
75
|
+
@build_britive
|
|
76
|
+
@britive_options(names='search_text,format,tenant,token,silent,passphrase,federation_provider')
|
|
77
|
+
def secrets(ctx, search_text, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
78
|
+
"""List secrets for the currently authenticated identity."""
|
|
79
|
+
ctx.obj.britive.list_secrets(search_text=search_text)
|
|
@@ -5,6 +5,7 @@ import json
|
|
|
5
5
|
import os
|
|
6
6
|
import random
|
|
7
7
|
import time
|
|
8
|
+
import uuid
|
|
8
9
|
import webbrowser
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import Optional
|
|
@@ -345,10 +346,15 @@ class EncryptedFileCredentialManager(CredentialManager):
|
|
|
345
346
|
try:
|
|
346
347
|
return self.string_encryptor.decrypt(ciphertext=encrypted_access_token)
|
|
347
348
|
except InvalidPassphraseException:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
try:
|
|
350
|
+
self.passphrase = str(uuid.getnode())
|
|
351
|
+
self.string_encryptor = StringEncryption(passphrase=self.passphrase)
|
|
352
|
+
return self.string_encryptor.decrypt(ciphertext=encrypted_access_token)
|
|
353
|
+
except InvalidPassphraseException:
|
|
354
|
+
self.cli.print('invalid passphrase provided - wiping credentials and forcing a re-authentication.')
|
|
355
|
+
self.delete()
|
|
356
|
+
self.credentials = self.load() or {}
|
|
357
|
+
return self.get_token()
|
|
352
358
|
|
|
353
359
|
def encrypt(self, decrypted_access_token: str):
|
|
354
360
|
return self.string_encryptor.encrypt(plaintext=decrypted_access_token)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import hashlib
|
|
2
3
|
import os
|
|
3
|
-
import
|
|
4
|
+
import platform
|
|
5
|
+
from getpass import getuser
|
|
4
6
|
from typing import Optional
|
|
5
7
|
|
|
6
8
|
from cryptography.fernet import Fernet, InvalidToken
|
|
@@ -15,7 +17,12 @@ class InvalidPassphraseException(Exception):
|
|
|
15
17
|
|
|
16
18
|
class StringEncryption:
|
|
17
19
|
def __init__(self, passphrase: Optional[str] = None):
|
|
18
|
-
self.passphrase =
|
|
20
|
+
self.passphrase = (
|
|
21
|
+
passphrase
|
|
22
|
+
or hashlib.sha256(
|
|
23
|
+
'|'.join([getuser(), *platform.uname()._asdict().values()]).replace(' ', '').encode('utf-8')
|
|
24
|
+
).hexdigest()
|
|
25
|
+
)
|
|
19
26
|
|
|
20
27
|
@staticmethod
|
|
21
28
|
def _salt():
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from sys import argv, exit
|
|
2
3
|
|
|
3
4
|
|
|
@@ -8,7 +9,12 @@ def get_args():
|
|
|
8
9
|
argv[1:], 't:T:p:F:hv', ['tenant=', 'token=', 'passphrase=', 'federation-provider=', 'help', 'version']
|
|
9
10
|
)[0]
|
|
10
11
|
|
|
11
|
-
args = {
|
|
12
|
+
args = {
|
|
13
|
+
'tenant': None,
|
|
14
|
+
'token': None,
|
|
15
|
+
'passphrase': os.getenv('PYBRITIVE_ENCRYPTED_CREDENTIAL_PASSPHRASE'),
|
|
16
|
+
'federation_provider': None,
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
for opt, arg in options:
|
|
14
20
|
if opt in ('-t', '--tenant'):
|
|
@@ -25,6 +25,7 @@ from pybritive.options.output_format import option as output_format
|
|
|
25
25
|
from pybritive.options.passphrase import option as passphrase
|
|
26
26
|
from pybritive.options.profile_type import option as profile_type
|
|
27
27
|
from pybritive.options.query import option as query
|
|
28
|
+
from pybritive.options.search_text import option as search_text
|
|
28
29
|
from pybritive.options.silent import option as silent
|
|
29
30
|
from pybritive.options.ssh_hostname import option as ssh_hostname
|
|
30
31
|
from pybritive.options.ssh_key_source import option as ssh_key_source
|
|
@@ -39,44 +40,45 @@ from pybritive.options.verbose import option as verbose
|
|
|
39
40
|
from pybritive.options.version import option as version
|
|
40
41
|
|
|
41
42
|
options_map = {
|
|
42
|
-
'tenant': tenant,
|
|
43
|
-
'token': token,
|
|
44
|
-
'format': output_format,
|
|
45
|
-
'output_format': output_format,
|
|
46
43
|
'alias': alias,
|
|
44
|
+
'aws_console_duration': aws_console_duration,
|
|
45
|
+
'aws_credentials_file': aws_credentials_file,
|
|
46
|
+
'aws_profile': aws_profile,
|
|
47
47
|
'blocktime': blocktime,
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'version': version,
|
|
51
|
-
'configure_tenant': configure_tenant,
|
|
48
|
+
'browser': browser,
|
|
49
|
+
'checked_out': checked_out,
|
|
52
50
|
'configure_alias': configure_alias,
|
|
51
|
+
'configure_backend': configure_backend,
|
|
53
52
|
'configure_prompt': configure_prompt,
|
|
54
|
-
'
|
|
55
|
-
'ticket_type': ticket_type,
|
|
56
|
-
'ticket_id': ticket_id,
|
|
57
|
-
'otp': otp,
|
|
58
|
-
'silent': silent,
|
|
53
|
+
'configure_tenant': configure_tenant,
|
|
59
54
|
'console': console,
|
|
60
|
-
'
|
|
55
|
+
'extend': extend,
|
|
56
|
+
'federation_provider': federation_provider,
|
|
61
57
|
'file': file,
|
|
62
|
-
'configure_backend': configure_backend,
|
|
63
|
-
'passphrase': passphrase,
|
|
64
58
|
'force_renew': force_renew,
|
|
65
|
-
'
|
|
66
|
-
'federation_provider': federation_provider,
|
|
59
|
+
'format': output_format,
|
|
67
60
|
'gcloud_key_file': gcloud_key_file,
|
|
68
|
-
'
|
|
61
|
+
'justification': justification,
|
|
62
|
+
'maxpolltime': maxpolltime,
|
|
63
|
+
'mode': mode,
|
|
64
|
+
'otp': otp,
|
|
65
|
+
'output_format': output_format,
|
|
66
|
+
'passphrase': passphrase,
|
|
67
|
+
'profile_type': profile_type,
|
|
69
68
|
'query': query,
|
|
69
|
+
'search_text': search_text,
|
|
70
|
+
'silent': silent,
|
|
70
71
|
'ssh_hostname': ssh_hostname,
|
|
71
|
-
'ssh_username': ssh_username,
|
|
72
|
-
'ssh_push_public_key': ssh_push_public_key,
|
|
73
|
-
'ssh_port': ssh_port,
|
|
74
72
|
'ssh_key_source': ssh_key_source,
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
73
|
+
'ssh_port': ssh_port,
|
|
74
|
+
'ssh_push_public_key': ssh_push_public_key,
|
|
75
|
+
'ssh_username': ssh_username,
|
|
76
|
+
'tenant': tenant,
|
|
77
|
+
'ticket_id': ticket_id,
|
|
78
|
+
'ticket_type': ticket_type,
|
|
79
|
+
'token': token,
|
|
80
|
+
'verbose': verbose,
|
|
81
|
+
'version': version,
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
|
|
@@ -80,6 +80,7 @@ src/pybritive/options/output_format.py
|
|
|
80
80
|
src/pybritive/options/passphrase.py
|
|
81
81
|
src/pybritive/options/profile_type.py
|
|
82
82
|
src/pybritive/options/query.py
|
|
83
|
+
src/pybritive/options/search_text.py
|
|
83
84
|
src/pybritive/options/silent.py
|
|
84
85
|
src/pybritive/options/ssh_hostname.py
|
|
85
86
|
src/pybritive/options/ssh_key_source.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.2.3'
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
|
|
3
|
-
from pybritive.helpers.build_britive import build_britive
|
|
4
|
-
from pybritive.options.britive_options import britive_options
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@click.group()
|
|
8
|
-
def ls():
|
|
9
|
-
"""List resources available for currently authenticated identity."""
|
|
10
|
-
pass
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@ls.command()
|
|
14
|
-
@build_britive
|
|
15
|
-
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
16
|
-
def applications(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
17
|
-
"""List applications for the currently authenticated identity."""
|
|
18
|
-
ctx.obj.britive.list_applications()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@ls.command()
|
|
22
|
-
@build_britive
|
|
23
|
-
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
24
|
-
def environments(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
25
|
-
"""List environments for the currently authenticated identity."""
|
|
26
|
-
ctx.obj.britive.list_environments()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@ls.command()
|
|
30
|
-
@build_britive
|
|
31
|
-
@britive_options(names='checked_out,profile_type,output_format,tenant,token,silent,passphrase,federation_provider')
|
|
32
|
-
def profiles(ctx, checked_out, profile_type, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
33
|
-
"""List profiles for the currently authenticated identity."""
|
|
34
|
-
ctx.obj.britive.list_profiles(checked_out=checked_out, profile_type=profile_type)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@ls.command()
|
|
38
|
-
@build_britive
|
|
39
|
-
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
40
|
-
def secrets(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
41
|
-
"""List secrets for the currently authenticated identity."""
|
|
42
|
-
ctx.obj.britive.list_secrets()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@ls.command()
|
|
46
|
-
@build_britive
|
|
47
|
-
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
48
|
-
def approvals(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
49
|
-
"""List approvals for the currently authenticated identity."""
|
|
50
|
-
ctx.obj.britive.list_approvals()
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@ls.command()
|
|
54
|
-
@build_britive
|
|
55
|
-
@britive_options(names='format,tenant,token,silent,passphrase,federation_provider')
|
|
56
|
-
def resources(ctx, output_format, tenant, token, silent, passphrase, federation_provider):
|
|
57
|
-
"""List resources for the currently authenticated identity."""
|
|
58
|
-
ctx.obj.britive.list_resources()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|