-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add credential fetcher for IAM user from system credential store
- Loading branch information
1 parent
2c6dde0
commit 71b3d4c
Showing
7 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
from .input_output.cli import parse_arguments | ||
from .input_output.cli import open_console_arguments, credential_process_arguments | ||
from .input_output.browser import open_console | ||
|
||
from .credentials import aws_credentials | ||
from .aws_console_login import signin_url | ||
from .aws_session_credential import aws_session_credential | ||
from .aws_login_api import signin_url | ||
from .system_credential_store import store_aws_credential, get_aws_credential | ||
|
||
__version__ = '0.3' | ||
__version__ = '0.4' | ||
|
||
|
||
def aws_console(): | ||
args = parse_arguments() | ||
args = open_console_arguments() | ||
|
||
if args.version: | ||
print(__version__) | ||
return | ||
__show_version_if_requested(args) | ||
|
||
creds, region_name = aws_credentials(args) | ||
creds, region_name = aws_session_credential(args.profile, args.region) | ||
url = signin_url(creds, region_name) | ||
|
||
open_console(url, args) | ||
open_console(url, args.clip, args.stdout) | ||
|
||
|
||
def aws_system_credential(): | ||
args = credential_process_arguments() | ||
|
||
__show_version_if_requested(args) | ||
|
||
if args.command == 'store': | ||
store_aws_credential(args.account_id, args.username, args.access_key, args.secret_key) | ||
elif args.command == 'get': | ||
get_aws_credential(args.account_id, args.username, args.access_key, args.credential_process) | ||
|
||
|
||
def __show_version_if_requested(args): | ||
if args.version: | ||
print(__version__) | ||
return |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import keyring | ||
import json | ||
|
||
|
||
def store_aws_credential(account_id, username, access_key, secret_key): | ||
service_name = '-'.join(filter(None, ['aws', account_id, username])) | ||
keyring.set_password(service_name, access_key, secret_key) | ||
|
||
|
||
def get_aws_credential(account_id, username, access_key, for_credential_process): | ||
service_name = '-'.join(filter(None, ['aws', account_id, username])) | ||
secret_key = keyring.get_password(service_name, access_key) | ||
|
||
if for_credential_process: | ||
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html | ||
print(json.dumps({ | ||
"Version": 1, | ||
"AccessKeyId": access_key, | ||
"SecretAccessKey": secret_key | ||
})) | ||
else: | ||
print(secret_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,14 @@ def find_version(*file_paths): | |
packages=find_packages(), | ||
entry_points={ | ||
'console_scripts': [ | ||
'aws-console = aws_console:aws_console' | ||
'aws-console = aws_console:aws_console', | ||
'aws-system-credential = aws_console:aws_system_credential' | ||
] | ||
}, | ||
install_requires=[ | ||
'boto3>=1.28', | ||
'pyperclip>=1.8,<1.9' | ||
'pyperclip>=1.8,<1.9', | ||
'keyring>=24.2,<24.3' | ||
], | ||
author='Snigdhajyoti Ghosh', | ||
author_email='[email protected]', | ||
|