Skip to content
Closed
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
8 changes: 8 additions & 0 deletions fluss-filesystems/fluss-fs-s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<properties>
<fs.s3.aws.version>1.12.319</fs.s3.aws.version>
<fs.s3.aws.v2.version>2.20.162</fs.s3.aws.v2.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -211,6 +212,13 @@
<version>${fs.s3.aws.version}</version>
</dependency>

<!-- AWS SDK v2 dependencies (for STS client) -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sts</artifactId>
<version>${fs.s3.aws.v2.version}</version>
</dependency>

<!-- Hadoop's s3 support classes (bundled) -->
<dependency>
<groupId>org.apache.hadoop</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import org.apache.fluss.fs.token.CredentialsJsonSerde;
import org.apache.fluss.fs.token.ObtainedSecurityToken;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.securitytoken.AWSSecurityTokenService;
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder;
import com.amazonaws.services.securitytoken.model.Credentials;
import com.amazonaws.services.securitytoken.model.GetSessionTokenResult;
import org.apache.hadoop.conf.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sts.StsClient;
import software.amazon.awssdk.services.sts.model.Credentials;
import software.amazon.awssdk.services.sts.model.GetSessionTokenResponse;

import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -70,31 +70,35 @@ public S3DelegationTokenProvider(String scheme, Configuration conf) {
public ObtainedSecurityToken obtainSecurityToken() {
LOG.info("Obtaining session credentials token with access key: {}", accessKey);

AWSSecurityTokenService stsClient =
AWSSecurityTokenServiceClientBuilder.standard()
.withRegion(region)
.withCredentials(
new AWSStaticCredentialsProvider(
new BasicAWSCredentials(accessKey, secretKey)))
.build();
GetSessionTokenResult sessionTokenResult = stsClient.getSessionToken();
Credentials credentials = sessionTokenResult.getCredentials();

LOG.info(
"Session credentials obtained successfully with access key: {} expiration: {}",
credentials.getAccessKeyId(),
credentials.getExpiration());

return new ObtainedSecurityToken(
scheme, toJson(credentials), credentials.getExpiration().getTime(), additionInfos);
try (StsClient stsClient =
StsClient.builder()
.region(Region.of(region))
.credentialsProvider(
StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey)))
.build()) {
GetSessionTokenResponse sessionTokenResult = stsClient.getSessionToken();
Credentials credentials = sessionTokenResult.credentials();

LOG.info(
"Session credentials obtained successfully with access key: {} expiration: {}",
credentials.accessKeyId(),
credentials.expiration());

return new ObtainedSecurityToken(
scheme,
toJson(credentials),
credentials.expiration().toEpochMilli(),
additionInfos);
}
}

private byte[] toJson(Credentials credentials) {
org.apache.fluss.fs.token.Credentials flussCredentials =
new org.apache.fluss.fs.token.Credentials(
credentials.getAccessKeyId(),
credentials.getSecretAccessKey(),
credentials.getSessionToken());
credentials.accessKeyId(),
credentials.secretAccessKey(),
credentials.sessionToken());
return CredentialsJsonSerde.toJson(flussCredentials);
}
}
29 changes: 29 additions & 0 deletions fluss-filesystems/fluss-fs-s3/src/main/resources/META-INF/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ This project bundles the following dependencies under the Apache Software Licens
- com.amazonaws:aws-java-sdk-s3:1.12.319
- com.amazonaws:aws-java-sdk-sts:1.12.319
- com.amazonaws:jmespath-java:1.12.319
- io.netty:netty-buffer:4.1.94.Final
- io.netty:netty-codec:4.1.94.Final
- io.netty:netty-codec-http:4.1.94.Final
- io.netty:netty-codec-http2:4.1.94.Final
- io.netty:netty-common:4.1.94.Final
- io.netty:netty-handler:4.1.94.Final
- io.netty:netty-resolver:4.1.94.Final
- io.netty:netty-transport:4.1.94.Final
- io.netty:netty-transport-classes-epoll:4.1.94.Final
- io.netty:netty-transport-native-unix-common:4.1.94.Final
- org.reactivestreams:reactive-streams:1.0.4
- software.amazon.awssdk:annotations:2.20.162
- software.amazon.awssdk:apache-client:2.20.162
- software.amazon.awssdk:auth:2.20.162
- software.amazon.awssdk:aws-core:2.20.162
- software.amazon.awssdk:aws-query-protocol:2.20.162
- software.amazon.awssdk:endpoints-spi:2.20.162
- software.amazon.awssdk:http-client-spi:2.20.162
- software.amazon.awssdk:json-utils:2.20.162
- software.amazon.awssdk:metrics-spi:2.20.162
- software.amazon.awssdk:netty-nio-client:2.20.162
- software.amazon.awssdk:profiles:2.20.162
- software.amazon.awssdk:protocol-core:2.20.162
- software.amazon.awssdk:regions:2.20.162
- software.amazon.awssdk:sdk-core:2.20.162
- software.amazon.awssdk:sts:2.20.162
- software.amazon.awssdk:third-party-jackson-core:2.20.162
- software.amazon.awssdk:utils:2.20.162
- software.amazon.eventstream:eventstream:1.0.1
- com.fasterxml.jackson.core:jackson-annotations:2.15.3
- com.fasterxml.jackson.core:jackson-core:2.15.3
- com.fasterxml.jackson.core:jackson-databind:2.15.3
Expand Down
Loading