Skip to main content

Command Line tool for AWS SSO Credentials

Project description

aws-sso

GitHub Actions status GitHub Actions status PyPi Version PyPI - Python Version PyPI - Downloads

This package provides a command line interface to get AWS credentials with AWS SSO.

The aws-cli package works on Python versions:

  • 3.7.x and greater

Attention!

This package relies on Selenium and Google Chrome to work. Therefore, you need Google Chrome and ChromeDriver to be installed.

This is being developped and tested on macOS, if you encounter problems on other platforms, please open an issue.

Dependencies

macOS

brew cask install chromedriver

Linux

¯\_(ツ)_/¯

Installation

pip install awssso

Getting Started

Help

For each command you can get help with --help flag.

usage: awssso configure [-h] [-p PROFILE] [-a AWS_PROFILE] [-f] [--url URL]
                        [--username USERNAME]

optional arguments:
  -h, --help            show this help message and exit
  -p PROFILE, --profile PROFILE
                        AWS SSO Profile (default: default)
  -a AWS_PROFILE, --aws-profile AWS_PROFILE
                        AWS CLI Profile (default: AWS_PROFILE, fallback: same
                        as --profile)
  -f, --force-refresh   force token refresh
  --url URL
  --username USERNAME

Configure a profile

$ awssso configure
[?] URL: https://d-0123456789.awsapps.com/start/
[?] AWS CLI profile: my-awssso-profile
[?] Username: me@example.com
[?] Password: **************
[?] MFA Code: 042042
[?] AWS Account: 000000000000 (Master)
   111111111111 (Log archive)
   222222222222 (Audit)
 > 000000000000 (Master)

[?] AWS Profile: AWSAdministratorAccess
   AWSServiceCatalogEndUserAccess
 > AWSAdministratorAccess

This will create a configuration file in ~/.awssso/config.

Get credentials

$ awssso login

This will get the credentials for the profile as defined in the configuration file and use aws-cli to set those credentials to the correct AWS Profile.


$ awssso login -e
export AWS_ACCESS_KEY_ID=ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY
export AWS_SESSION_TOKEN=SESSION_TOKEN

This will echo export commands to stdout ; can be used like this $(awssso login -e)


$ awssso login -c
https://signin.aws.amazon.com/federation?Action=login&Destination=https%3A%2F%2Fconsole.aws.amazon.com%2F&SigninToken=TOKEN

This will generate a Sign In URL to the AWS Console ; URL will open in a new tab if used with --browser.


You can also use this tool as a credential_process for awscli. To do so, configure your awscli configuration file like so:

[profile my-sso-profile]
credential_process = awssso login -p my-awssso-profile --json

And then simply use awscli normally:

$ aws --profile my-sso-profile s3 ls

Base concepts

aws-sso has its own configuration file (~/.awssso/config).
Each section in this file corresponds to an AWS SSO profile. Those profiles are different from AWS profiles.

When using the login command, it'll set credentials for the configured AWS Profile by invoking aws configure.

Inside ~/.awssso/ are also stored cookie files for each pair of username / url. This allows not prompting for MFA code at each login.

Secrets are stored using keyring so for example on macOS they are stored in Keychain.
For each username / url aws-sso stores three secrets:

  • password
  • authn-token
  • authn-expiry-date

aws-sso doesn't make new login attempts until authn-token is expired.
aws-sso also stores credentials using keyring to avoid making too many STS calls.

Releases

The release notes for AWS SSO can be found here.

Known issues

Known issues can be found here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awssso-1.1.1.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

awssso-1.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file awssso-1.1.1.tar.gz.

File metadata

  • Download URL: awssso-1.1.1.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for awssso-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9fc1b3299df40bf0c393ef49d6c9136f422f51a7dfc382d832bec1a679570049
MD5 b9253e4a4ce67b86214f0611623f1e67
BLAKE2b-256 c7a3d081c049585d3b93d7e34a3efa71fccc29a68715f4e026c2dcd07eb03d43

See more details on using hashes here.

File details

Details for the file awssso-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: awssso-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for awssso-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 57e91e83a437e06729ad0ea6e6d03cda1c6be43d665a685e2eb28dd44ea6cfbf
MD5 ddac89981c2801145b35d5094abcbac4
BLAKE2b-256 6d4380c23f09e3c5ecba1da8e79fd194858d2d0ff2a26f4351b49ff205844bf9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page