Skip to content

Support using STS session tokens in addition to keys#124

Open
avalade wants to merge 1 commit intoNixOS:masterfrom
avalade:master
Open

Support using STS session tokens in addition to keys#124
avalade wants to merge 1 commit intoNixOS:masterfrom
avalade:master

Conversation

@avalade
Copy link
Copy Markdown

@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.

1 participant