Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using STS session tokens in addition to keys #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

avalade
Copy link

@avalade avalade commented Jan 2, 2021

Another method for authentication to AWS is using STS keys. This is common when
using 2FA or when using an identity account that ties together other delegated
accounts in AWS. Session tokens are supported by Boto, we just need to expose
them to our connection methods.

This PR adds support for authenticating with session tokens when using
environment variables for authentication. It does that by modifying the return
of fetch_aws_secret_key to return a tri-tuple where the 3rd item of the tuple
is the contents of AWS_SECURITY_TOKEN or AWS_SESSION_TOKEN, if available in the
environment.

Previous versions of different AWS tooling has used AWS_SECURITY_TOKEN as the
default environment variable. However, the current standard is
AWS_SESSION_TOKEN. This PR will use either of them with a preference towards
the AWS_SESSION_TOKEN environment variable.

In the case that ~/.ec2-key-pairs or ~/.aws/credentials is being used for
authentication, we just return None for the session token.

Another method for authentication to AWS is using STS keys.  This is common when
using 2FA or when using an identity account that ties together other delegated
accounts in AWS.  Session tokens are supported by Boto, we just need to expose
them to our connection methods.

This PR adds support for authenticating with session tokens when using
environment variables for authentication.  It does that by modifying the return
of `fetch_aws_secret_key` to return a tri-tuple where the 3rd item of the tuple
is the contents of AWS_SECURITY_TOKEN or AWS_SESSION_TOKEN, if available in the
environment.

Previous versions of different AWS tooling has used AWS_SECURITY_TOKEN as the
default environment variable.  However, the current standard is
AWS_SESSION_TOKEN.  This PR will use either of them with a preference towards
the AWS_SESSION_TOKEN environment variable.

In the case that ~/.ec2-key-pairs or ~/.aws/credentials is being used for
authentication, we just return `None` for the session token.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant