Skip to content

Commit debe32a

Browse files
committed
Remove retry and show original error when assuming role with web identity fails.
1 parent cde4511 commit debe32a

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

s3/src/main/java/ch/cyberduck/core/sts/STSAssumeRoleWithWebIdentityCredentialsStrategy.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import ch.cyberduck.core.Profile;
2222
import ch.cyberduck.core.TemporaryAccessTokens;
2323
import ch.cyberduck.core.exception.BackgroundException;
24-
import ch.cyberduck.core.exception.LoginFailureException;
2524
import ch.cyberduck.core.oauth.OAuth2RequestInterceptor;
2625
import ch.cyberduck.core.preferences.ProxyPreferencesReader;
2726
import ch.cyberduck.core.s3.S3CredentialsStrategy;
@@ -54,14 +53,7 @@ public STSAssumeRoleWithWebIdentityCredentialsStrategy(final OAuth2RequestInterc
5453
@Override
5554
public TemporaryAccessTokens refresh(final Credentials credentials) throws BackgroundException {
5655
final String arn = new ProxyPreferencesReader(host, credentials).getProperty(Profile.STS_ROLE_ARN_PROPERTY_KEY, "s3.assumerole.rolearn");
57-
try {
58-
log.debug("Retrieve temporary credentials with {} for role ARN {}", credentials, arn);
59-
return this.assumeRoleWithWebIdentity(oauth.validate(credentials.getOauth()), arn);
60-
}
61-
catch(LoginFailureException e) {
62-
// Expired or invalid OAuth tokens
63-
log.warn("Failure {} authorizing. Retry with refreshed OAuth tokens", e.getMessage());
64-
return this.assumeRoleWithWebIdentity(oauth.authorize(), arn);
65-
}
56+
log.debug("Retrieve temporary credentials with {} for role ARN {}", credentials, arn);
57+
return this.assumeRoleWithWebIdentity(oauth.validate(credentials.getOauth()), arn);
6658
}
6759
}

s3/src/test/java/ch/cyberduck/core/sts/AssumeRoleWithWebIdentityAuthenticationTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void testTokenRefresh() throws BackgroundException, InterruptedException
131131
* Fetch OpenID Connect Id token initially fails because of invalid refresh token. Must re-run OAuth flow.
132132
*/
133133
@Test
134-
public void testLoginInvalidOAuthTokensLogin() throws Exception {
134+
public void testLoginInvalidOAuthTokens() throws Exception {
135135
final Protocol profile = new ProfilePlistReader(new ProtocolFactory(new HashSet<>(Collections.singleton(new S3Protocol())))).read(
136136
AbstractAssumeRoleWithWebIdentityTest.class.getResourceAsStream("/S3 (OIDC).cyberduckprofile"));
137137
final Credentials credentials = new Credentials("rouser", "rouser")
@@ -146,12 +146,7 @@ public void testLoginInvalidOAuthTokensLogin() throws Exception {
146146
assertNotNull(session.open(new DisabledProxyFinder(), new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback()));
147147
assertTrue(session.isConnected());
148148
assertNotNull(session.getClient());
149-
session.login(new DisabledLoginCallback(), new DisabledCancelCallback());
150-
assertNotEquals(OAuthTokens.EMPTY, credentials.getOauth());
151-
assertNotEquals(TemporaryAccessTokens.EMPTY, credentials.getTokens());
152-
credentials.setOauth(OAuthTokens.EMPTY).setTokens(TemporaryAccessTokens.EMPTY);
153-
new S3BucketListService(session).list(
154-
new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener());
149+
assertThrows(LoginFailureException.class, () -> session.login(new DisabledLoginCallback(), new DisabledCancelCallback()));
155150
}
156151

157152
/**

0 commit comments

Comments
 (0)