This tool was ported from a python script in the AWS samples s3 bucket [1].
However, it didn't work for me out of the box and used python 3 (by the time it got to me, I got it from a 3rd party) and I only had python 2.7 and I wanted to learn more go.
For when I can't remember, STS stands for Security Token Service
go get -u github.com/NearlyUnique/awsSts
Download the Current release for your platform.
It works on Windows, I've tested linux (bash on windows) there is no reason it won't work on OSX.
Common scenario;
- My STS web login web page is here:
https://sts.domain.company.org/adfs/ls/IdpInitiatedSignOn.aspx?loginToRp=urn:amazon:webservices
- My other scripts are going to use the
default
AWS profile - Automatically select the role
arn:aws:iam::123456789:role/my-role
- Leave running in a state where I can
auto
matically refresh my token with one key press when it expires in an hour
awsSts logon --url https://sts.domain.company.org/adfs/ls/IdpInitiatedSignOn.aspx?loginToRp=urn:amazon:webservices --profile default --role arn:aws:iam::123456789:role/my-role
--help
for full details, including details of all parameters that can be read from environment.
- Override credential file location via flag
- Keep running and auto refresh before expiry (optional)
- Deal with naming of INPUT tags in the login form, the Python sample did some work in this area, I want to improve the guessing ability and allow the user to define it if we can't guess.
- add command to ease iam user creation
- add command to rotate iam user secrets
- Auto upgrade
- use
runtime.GOOS
and_VERISON
- call
GET https://api.github.com/repos/NearlyUnique/awsSts/releases/latest
{
"tag_name": "0.7",
"assets": [
{
"name": "awsSts-0.7-linux",
"browser_download_url": "https://some-url"
}
]
}`
- the
browser_download_url
may give a redirect
- Download the login form, we need the cookies
- Fill in the user name and password
- Post form back
- Parse the response HTML form
- Find the
SAMLResponse
INPUT element - base64 decode it (it's now XML)
- Extract the Roles, select one
- Call AWS
AssumeRoleWithSAML
- update the credentials ini file with the result
[1] https://s3.amazonaws.com/awsiammedia/public/sample/SAMLAPICLIADFS/samlapi_formauth_adfs3.py