fix(sts): cap account-root token durations at one hour (#7125)

* fix(sts): cap account-root token durations at one hour

Cap GetSessionToken and GetFederationToken credentials issued to the account-root identity at one hour, preserving IAM user durations and validation ordering.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

* test(sts): bound root token expiry by request time

Check the one-hour default using timestamps captured before the request and after the response, allowing millisecond wire precision. Preserve the root duration cap.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

---------

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-10-31 17:01:47 -04:00
1 parent dc04c47791
commit 81e1dbc573
5 files changed
+158 -3

No files matched your search

@@ -350,11 +350,16 @@ class StsTest {
@Test
void getSessionTokenDefaultDuration() {
Instant beforeRequest = Instant.now();
GetSessionTokenResponse response = sts.getSessionToken(
GetSessionTokenRequest.builder().build());
Instant afterResponse = Instant.now();
assertThat(response.credentials()).isNotNull();
assertThat(response.credentials().expiration()).isAfter(Instant.now().plusSeconds(3600));
// Root credentials default to one hour; wire timestamps have millisecond precision.
assertThat(response.credentials().expiration()).isBetween(
beforeRequest.plusSeconds(3600).minusMillis(1),
afterResponse.plusSeconds(3600).plusMillis(1));
}
@Test