Skip to content

Commit b57d48f

Browse files
authored
fix(credential-provider-sso): accept all unexpired tokens as unexpired (#5124)
1 parent 6af11f7 commit b57d48f

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

packages/credential-provider-sso/src/resolveSSOCredentials.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ describe(resolveSSOCredentials.name, () => {
9797
const mockExpiredToken = { ...mockToken, expiresAt: new Date(Date.now() - 60 * 1000).toISOString() };
9898
(getSSOTokenFromFile as jest.Mock).mockResolvedValue(mockExpiredToken);
9999
});
100-
101-
it("throws error if SSO session expires in <15 mins", async () => {
102-
const mockExpiredToken = { ...mockToken, expiresAt: new Date(Date.now() + 899 * 1000).toISOString() };
103-
(getSSOTokenFromFile as jest.Mock).mockResolvedValue(mockExpiredToken);
104-
});
105100
});
106101

107102
describe("throws error on sso.getRoleCredentials call", () => {

packages/credential-provider-sso/src/resolveSSOCredentials.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ import { AwsCredentialIdentity } from "@smithy/types";
66

77
import { FromSSOInit, SsoCredentialsParameters } from "./fromSSO";
88

9-
/**
10-
* The time window (15 mins) that SDK will treat the SSO token expires in before the defined expiration date in token.
11-
* This is needed because server side may have invalidated the token before the defined expiration date.
12-
*
13-
* @internal
14-
*/
15-
const EXPIRE_WINDOW_MS = 15 * 60 * 1000;
16-
179
const SHOULD_FAIL_CREDENTIAL_CHAIN = false;
1810

1911
/**
@@ -52,7 +44,7 @@ export const resolveSSOCredentials = async ({
5244
}
5345
}
5446

55-
if (new Date(token.expiresAt).getTime() - Date.now() <= EXPIRE_WINDOW_MS) {
47+
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
5648
throw new CredentialsProviderError(
5749
`The SSO session associated with this profile has expired. ${refreshMessage}`,
5850
SHOULD_FAIL_CREDENTIAL_CHAIN

0 commit comments

Comments
 (0)