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

Allow token to be passed as env var along with password #262

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

Conversation

avengerpenguin
Copy link

I wanted better integration with AWS cli support for external processes so I have made this change to allow 2FA tokens to be passed as an env var too. I tried to follow the patterns for password, but it might need some polish.

This allows me to do:

export AZURE_VERIFICATION_CODE=$(oathtool --totp --base32 $SECRET)

as part of a script that immediately then runs this tool.

I can then configure AWS cli to use this overall script automatically on expiry:

credential_process=/path/to/script

To make this integrate nicely, I also had to make some extra changes:

  • Use console.error not console.log for all information-only output.

  • Add a single console.log to echo out the credentials as JSON at the end.

The 2nd point should probably be a flag to switch between the original version (where it writes the credentials file for you) vs. this mode where it merely writes the credentials so as to compose with AWS cli's external process support.

This arguably makes the change do more than one thing so maybe it could be split up or at least have that flag added. I thought it was worth getting feedback before I do any more though.

I wanted better integration with [AWS cli support for external
processes](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html)
so I have made this change to allow 2FA tokens to be passed as an env
var too. I tried to follow the patterns for password, but it might
need some polish.

This allows me to do:

```
export AZURE_VERIFICATION_CODE=$(oathtool --totp --base32 $SECRET)
```

as part of a script that immediately then runs this tool.

I can _then_ configure AWS cli to use this overall script
automatically on expiry:

```
credential_process=/path/to/script
```

To make this integrate nicely, I also had to make some extra changes:

- Use `console.error` not `console.log` for all information-only
output.

- Add a single `console.log` to echo out the credentials as JSON at
the end.

- Add a `--print` flag to enable the stdout behaviour to prevent the
default behaviour where it writes the file. This avoids two methods
trying to write the same file.

This arguably makes the change do more than one thing so maybe it
could be split. I thought it was worth getting feedback before I do
any more though.
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

2 participants