diff --git a/app/arguments.py b/app/arguments.py index b6b7a77..ee6b0eb 100644 --- a/app/arguments.py +++ b/app/arguments.py @@ -20,7 +20,7 @@ def parse(args): help='Overwrite region to login to') parser.add_argument('--set-access-key', action='store_true', help='set access key') - parser.add_argument('--rotate-access-key', action='store_true', + parser.add_argument('--rotate-access-key', help='rotate access key') parser.add_argument('-o', '--oneshot', action='store_true', help='When used in combination with --login, the program will finish after login instead of running an infinite refresh loop') diff --git a/app/cli/cli.py b/app/cli/cli.py index 787c1f2..933a1fe 100755 --- a/app/cli/cli.py +++ b/app/cli/cli.py @@ -60,17 +60,23 @@ def logout(self): logout_result = self.core.logout() self._check_and_signal_error(logout_result) - def rotate_access_key(self): - rotate_result = self.core.rotate_access_key() + def rotate_access_key(self, key_name): + rotate_result = self.core.rotate_access_key(key_name=key_name, mfa_callback=self.ask_for_mfa_token) if not self._check_and_signal_error(rotate_result): return self._info('key was successfully rotated') def set_access_key(self): + while True: + key_name = input('Key Name: ') + if not key_name.startswith('access-key'): + self._error('key name must start with \'access-key\'') + else: + break key_id = getpass(prompt='Key ID: ') - access_key = getpass(prompt='Secret Access Key: ') - self.core.set_access_key(key_id=key_id, key_secret=access_key) - self._info('key was successfully rotated') + key_secret = getpass(prompt='Secret Access Key: ') + self.core.set_access_key(key_name=key_name, key_id=key_id, key_secret=key_secret) + self._info('key was successfully set') @staticmethod def ask_for_mfa_token(): diff --git a/app/cli/main.py b/app/cli/main.py index f8751ed..043a6ec 100644 --- a/app/cli/main.py +++ b/app/cli/main.py @@ -10,6 +10,6 @@ def start_cli(args): if args.logout: cli.logout() if args.rotate_access_key: - cli.rotate_access_key() + cli.rotate_access_key(args.rotate_access_key) if args.set_access_key: cli.set_access_key() diff --git a/app/core/core.py b/app/core/core.py index 63f142e..bbe8ac7 100644 --- a/app/core/core.py +++ b/app/core/core.py @@ -199,8 +199,8 @@ def _handle_support_files(profile_group: ProfileGroup): files.write_active_group_file(profile_group.name) @staticmethod - def set_access_key(key_name: str, key_id: str, access_key: str): - credentials.set_access_key(key_name=key_name, key_id=key_id, key_secret=access_key) + def set_access_key(key_name: str, key_id: str, key_secret: str): + credentials.set_access_key(key_name=key_name, key_id=key_id, key_secret=key_secret) @staticmethod def get_access_key_list(): diff --git a/app/gui/gui.py b/app/gui/gui.py index d244096..c7b64a4 100644 --- a/app/gui/gui.py +++ b/app/gui/gui.py @@ -93,8 +93,8 @@ def edit_config(self, config: Config): self.tray_icon.populate_context_menu(self.core.get_profile_group_list()) self._to_reset_state() - def set_access_key(self, key_name, key_id, access_key): - self.core.set_access_key(key_name=key_name, key_id=key_id, access_key=access_key) + def set_access_key(self, key_name, key_id, key_secret): + self.core.set_access_key(key_name=key_name, key_id=key_id, key_secret=key_secret) self._signal('Success', 'access key was set') def rotate_access_key(self, key_name: str):