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

Fix #15257. #15258

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ else if(!profiles.containsKey(basicProfile.getRoleSourceProfile())) {
return credentials;
}
return credentials.withTokens(new TemporaryAccessTokens(
cached.accessKey, cached.secretKey, cached.sessionToken, Long.valueOf(cached.expiration)));
cached.accessKey, cached.secretKey, cached.sessionToken,
Instant.parse(cached.expiration).toEpochMilli()));
}
if(tokenCode != null) {
// Obtain session token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@ public void readSuccessForValidAWSCredentialsProfileEntry() throws Exception {
assertEquals("EXAMPLESECRETKEY", verify.getTokens().getSecretAccessKey());
assertEquals("EXAMPLETOKEN", verify.getTokens().getSessionToken());
}

@Test
public void readSSOCachedTemporaryTokens() throws Exception {
final Credentials verify = new S3CredentialsConfigurator(LocalFactory.get(new File("src/test/resources/valid/.aws").getAbsolutePath())
, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DisabledPasswordCallback())
.reload().configure(new Host(new TestProtocol(), StringUtils.EMPTY, new Credentials("ReadOnlyAccess-189584543480")));
assertEquals("TESTACCESSKEY", verify.getTokens().getAccessKeyId());
assertEquals("TESTSECRETKEY", verify.getTokens().getSecretAccessKey());
assertEquals("TESTSESSIONTOKEN", verify.getTokens().getSessionToken());
assertEquals(3497005724000L, verify.getTokens().getExpiryInMilliseconds(), 0L);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ProviderType": "sso",
"Credentials": {
"AccessKeyId": "TESTACCESSKEY",
"SecretAccessKey": "TESTSECRETKEY",
"SessionToken": "TESTSESSIONTOKEN",
"Expiration": "2080-10-24T14:28:44Z"
}
}
6 changes: 6 additions & 0 deletions s3/src/test/resources/valid/.aws/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[profile ReadOnlyAccess-189584543480]
sso_start_url = https://d-90679a6e6a.awsapps.com/start
sso_region = us-east-1
sso_account_id = 189584543480
sso_role_name = ReadOnlyAccess
region = eu-west-1