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

CLI SSO auth w/o a web browser #353

Open
synfinatic opened this issue May 2, 2022 · 8 comments
Open

CLI SSO auth w/o a web browser #353

synfinatic opened this issue May 2, 2022 · 8 comments
Labels
help-wanted Extra attention is needed idea Things to think about

Comments

@synfinatic
Copy link
Owner

Would be great to not have to rely on opening a URL in a GUI web browser and have the user login to AWS SSO. Would be preferred to perform the auth workflow via the CLI. I tried using Lynx, but that doesn't work because AWS SSO requires JS.

Can we integrate a JS enabled web scraper and somehow interact with the rendered pages? Lots of possible libraries listed here: https://github.com/lorien/awesome-web-scraping/blob/master/golang.md

@synfinatic synfinatic added help-wanted Extra attention is needed idea Things to think about labels May 2, 2022
@synfinatic synfinatic changed the title CLI SSO auth CLI SSO auth w/o a web browser May 11, 2022
@fggrtech
Copy link

fggrtech commented Dec 7, 2022

Interesting. I ran across the option of leveraging a containerized environment which cannot invoke the hosts web browser, and wouldn't mind this feature.

@synfinatic
Copy link
Owner Author

synfinatic commented Dec 7, 2022

@fggrtech Can you give more info about your containerized ENV / workflow? What is the use case? How long are these containers running? Do they run locally? Can they talk to services on your local laptop/PC?

@fggrtech
Copy link

fggrtech commented Dec 7, 2022

I was experimenting with providing a containerized linux IDE (vim, emacs) that had built-in support for AWS via this tooling. The hosting environment may differ (x86, arm, win, osx, linux), thus making communication for the external browser challenging.

This approach interests me, as the path for providing a container having the tooling pre-configured and allowing for different environments (node, jdk, all differing version combinations) is appealing.

I was able to experiment with an alpine linux container image, a locally built (make + go) binary on the image, and execute the resulting aws-sso. However, integration with the browser (js) auth mode isn't workable.

@synfinatic
Copy link
Owner Author

For this use case you might just try using --url-action=print and let the user copy & paste the URL into their local browser.

@fggrtech
Copy link

fggrtech commented Dec 9, 2022

I'll give that a try.

I've also experimented with invoking aws-sso on the host system to completion, followed by a env | grep -E "AWS_" > ~/.aws-current-env && docker exec -it --env-file ~/.aws-current-env bash.

That propagates the results of the aws-sso-cli login process, but i'm unsure if there is more that needs to occur to utilize it.

@synfinatic
Copy link
Owner Author

you can indeed export the AWS_* environment variables and pass that in via the environment or mount it as ~/.aws/credentials, but you won't be able to refresh the IAM credentials that way which will cause issues for long running containers since the reds are limited to X hours (defined by the admin).

The advantage of using --url-action=print is that you get a local SSO Access Token which is typically good for a longer period of time (potentially days) and can be used to not just refresh your IAM creds, but switch between roles in your container.

@synfinatic
Copy link
Owner Author

also, I should mention, if you want to do the environmental variable route aws-sso eval would likely be easier than doing the env | grep trick.

@fggrtech
Copy link

For this use case you might just try using --url-action=print and let the user copy & paste the URL into their local browser.

This works as-expected. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Extra attention is needed idea Things to think about
Projects
None yet
Development

No branches or pull requests

2 participants