kopia lustrzana https://github.com/gaul/s3proxy
Support IRSA for aws-s3 provider
rodzic
da99e5be4e
commit
25110e5b26
6
pom.xml
6
pom.xml
|
@ -394,6 +394,11 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-sts</artifactId>
|
||||
<version>1.12.261</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>args4j</groupId>
|
||||
<artifactId>args4j</artifactId>
|
||||
|
@ -510,7 +515,6 @@
|
|||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- tests dependencies -->
|
||||
<dependency>
|
||||
|
|
|
@ -35,15 +35,21 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.amazonaws.auth.AWSCredentials;
|
||||
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||
import com.amazonaws.auth.AWSSessionCredentials;
|
||||
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.MoreFiles;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.JcloudsVersion;
|
||||
import org.jclouds.aws.domain.SessionCredentials;
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.concurrent.DynamicExecutors;
|
||||
|
@ -52,6 +58,7 @@ import org.jclouds.location.reference.LocationConstants;
|
|||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||
import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext;
|
||||
import org.jclouds.s3.domain.ObjectMetadata.StorageClass;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.Option;
|
||||
|
@ -376,7 +383,6 @@ public final class Main {
|
|||
|
||||
ContextBuilder builder = ContextBuilder
|
||||
.newBuilder(provider)
|
||||
.credentials(identity, credential)
|
||||
.modules(List.of(
|
||||
new SLF4JLoggingModule(),
|
||||
new ExecutorServiceModule(executorService)))
|
||||
|
@ -385,6 +391,34 @@ public final class Main {
|
|||
builder = builder.endpoint(endpoint);
|
||||
}
|
||||
|
||||
if ((identity.isEmpty() || credential.isEmpty()) && provider.equals("aws-s3")) {
|
||||
Supplier<Credentials> credentialsSupplier = new Supplier<Credentials>() {
|
||||
@Override
|
||||
public Credentials get() {
|
||||
AWSCredentialsProvider authChain = DefaultAWSCredentialsProviderChain.getInstance();
|
||||
AWSCredentials newCreds = authChain.getCredentials();
|
||||
Credentials jcloudCred = null;
|
||||
|
||||
if (newCreds instanceof AWSSessionCredentials) {
|
||||
jcloudCred = SessionCredentials.builder()
|
||||
.accessKeyId(newCreds.getAWSAccessKeyId())
|
||||
.secretAccessKey(newCreds.getAWSSecretKey())
|
||||
.sessionToken(((AWSSessionCredentials) newCreds).getSessionToken())
|
||||
.build();
|
||||
} else {
|
||||
jcloudCred = new Credentials(
|
||||
newCreds.getAWSAccessKeyId(), newCreds.getAWSSecretKey()
|
||||
);
|
||||
}
|
||||
|
||||
return jcloudCred;
|
||||
}
|
||||
};
|
||||
builder = builder.credentialsSupplier(credentialsSupplier);
|
||||
} else {
|
||||
builder = builder.credentials(identity, credential);
|
||||
}
|
||||
|
||||
BlobStoreContext context = builder.build(BlobStoreContext.class);
|
||||
BlobStore blobStore;
|
||||
if (context instanceof RegionScopedBlobStoreContext &&
|
||||
|
|
Ładowanie…
Reference in New Issue