aws / aws/aws-cli

`aws sso login` should respect credential expiration

Open
#6,948 17 comments 39 reactions 0 assignees View on GitHub
community contribution-ready feature-request p2 sso
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the feature

Currently, `aws sso login` goes through the log in process whenever it's called. So if I have two profiles `foo` and `bar` that share the same AWS SSO configuration (i.e., `sso_start_url` and `sso_region`), when I call `aws sso login --profile foo`, it will pop up a browser window, log me in, etc., resulting in a valid token being cached in `~/.aws/sso/cache`. If I then call `aws sso login --profile bar` (or `aws sso login --profile foo` again, for that matter), despite having a valid token for that config, it will go through the entire login process again, resulting in a new token.

### Use Case

It's unnecessary work, and it's exacerbated by the argument to `aws sso login` being `--profile`, which leads people to think they need to call it whenever they're using a particular profile (I wrote [an explainer](https://ben11kehoe.medium.com/you-only-need-to-call-aws-sso-login-once-for-all-your-profiles-41a334e1b37e) to help people understand they don't need to do that).

### Proposed Solution

`aws sso login` should check the expiration of the cached token, and exit out successfully if the token is not expired. There should be a `--force-refresh` option to override this.

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CLI version used

N/A

### Environment details (OS name and version, etc.)

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.