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

Feature: Automatically logout before login #721

Open
tm-lmathieu opened this issue Feb 11, 2021 · 6 comments
Open

Feature: Automatically logout before login #721

tm-lmathieu opened this issue Feb 11, 2021 · 6 comments
Labels

Comments

@tm-lmathieu
Copy link

Using aws-vault login while already logged in opens a window that tells you to log out. Could there be a way to logout automatically?

@moltar
Copy link

moltar commented Jun 12, 2021

Came here to open the same issue 😁

I noticed that SSO console links for "Management Console" do not require logout. Clicking any of the links in SSO logs you in right away.

While when aws-vault login $PROFILE brings up a "you need to logout" screen first when switching between accounts.

Links point to:

https://${SSO_SUBDOMAIN}.awsapps.com/start/#/saml/custom/${ACCOUNT_ID}%20%28${ACCOUNT_NAME}%29/${SOME_SORT_OF_TOKEN}%3D%3D

Management Console

This works automatically.

screenshot-20210612T074252-GlsrHYHv


Manual Logout

screenshot-20210612T074544-xsi0i0gl

@stale
Copy link

stale bot commented Jan 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 3, 2022
@stale stale bot closed this as completed Apr 16, 2022
@moltar

This comment was marked as off-topic.

@mtibben mtibben closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
@mtibben mtibben reopened this Feb 28, 2023
@mtibben mtibben added feature and removed stale labels Feb 28, 2023
@cob16
Copy link

cob16 commented Oct 25, 2023

This annoys me quite a lot as well.
I thought about making a browser extension that would auto logout and reload the link when it detected this page, but I settled on making a quick bash function that I put in my ~/.bashrc instead.

aws-vault() {
    if [[ $@ = login* ]]; then
        echo "logging out first"
        command xdg-open https://eu-west-2.console.aws.amazon.com/cloudformation/logout\!doLogout
        command aws-vault "$@"
    else
        command aws-vault "$@"
    fi
}
  • This function logs out your browser from AWS before running aws-vault login.
  • xdg-open opens the default browser (depending on your machine you may need a different command)

Hope that helps you @tm-lmathieu & @moltar 😁

@tm-lmathieu
Copy link
Author

I also found a solution, I should have posted it here a good while ago. Here's my bash alias:

alias yalogin='f(){sensible-browser --new-window https://signin.aws.amazon.com/oauth\?Action\=logout && sleep 1 && wmctrl -c :ACTIVE: && aws-vault --prompt ykman login $1}; f'

It launches a new window of my default browser on the logout URL, waits for one second, uses wmcrtl to close the active window, then runs the login command with my Yubikey for the 2FA.

@amanibhavam
Copy link

amanibhavam commented Nov 30, 2023

I found a way to log out and redirect to the federated login link using https://signin.aws.amazon.com/oauth?Action=logout&redirect_uri=${aws_vault_login_url}"

# modify the federated login link to use the us-east-1 endpoint
url=$(aws-vault login "${account}" -s | sed 's#://#://us-east-1.#')

# urlencode the federated link because it will be embedded as a query parameter
encoded_url=$(printf "%s" "$url" | python -c 'import sys; from urllib.parse import quote_plus; print(quote_plus(sys.stdin.read().strip()))')

# use the oauth URL with Action=logout and a redirect_uri set to the federated link
open "https://signin.aws.amazon.com/oauth?Action=logout&redirect_uri=${encoded_url}"

I could only get this to work if the federated link is modified to use the us-east-1 endpoint. Didn't find documentation on why this trick works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants