Skip to content

Conversation

@axelson
Copy link

@axelson axelson commented Jul 14, 2025

Refreshes Application Session tokens after they expire in an hour

Fixes ex-aws#1100

AWS SSO has two different session concepts, Application Session tokens and a sign in session:
https://docs.aws.amazon.com/singlesignon/latest/userguide/authconcept.html#sessionsconcept

Depending on the configured expiration time for the aws sso login session can be valid for up to 90 days, while the "application session" token which is always only valid for 1 hour (I assume this is a security measure so the session can be revoked without waiting a full 90 days). While the sign in session is valid, the refresh token can be used to generate new application session tokens for up to the full 90 days.

So we can use the refresh token to retrieve another Application Session token with the CreateToken call: https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html

Here's the base url: "https://oidc.#{region}.amazonaws.com/token"

And here's an example of the payload (where the sso_cache is from ~/.aws/sso/cache):

payload = %{
  "grantType" => "refresh_token",
  "clientId" => sso_cache["clientId"],
  "clientSecret" => sso_cache["clientSecret"],
  "refreshToken" => sso_cache["refreshToken"]
}

TODO:

  • Clean up so it can be upstreamed (improve expiration detection)
  • Should we be writing the updated token back into the cache?

jasonlatta and others added 3 commits June 27, 2025 08:50
Bumps [req](https://github.com/wojtekmach/req) from 0.5.10 to 0.5.15.
- [Release notes](https://github.com/wojtekmach/req/releases)
- [Changelog](https://github.com/wojtekmach/req/blob/main/CHANGELOG.md)
- [Commits](wojtekmach/req@v0.5.10...v0.5.15)

---
updated-dependencies:
- dependency-name: req
  dependency-version: 0.5.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
@axelson axelson marked this pull request as ready for review July 14, 2025 20:12
riiwo and others added 18 commits August 1, 2025 14:59
Redshift data API is used for interacting with data in Redshift warehouse.
The redshift endpoints are for infrastructure management instead. Adds
capabilities to use Redshift Data API documented here: [redshift-data]

[redshift-data]: https://docs.aws.amazon.com/redshift-data/latest/APIReference/Welcome.html
Add bedrock endpoints to gov cloud partition
Add Redshift Data API endpoints
Bumps [hackney](https://github.com/benoitc/hackney) from 1.24.1 to 1.25.0.
- [Release notes](https://github.com/benoitc/hackney/releases)
- [Changelog](https://github.com/benoitc/hackney/blob/master/NEWS.md)
- [Commits](benoitc/hackney@1.24.1...1.25.0)

---
updated-dependencies:
- dependency-name: hackney
  dependency-version: 1.25.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Specifically: `(RuntimeError) places not found in partition aws-us-gov`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Improve caching for SSO credentials workflow

5 participants