Skip to content

Commit 4edd890

Browse files
committed
HADOOP-18975 AWS SDK v2: support FIPS endpoints
Adds a new option `fs.s3a.endpoint.fips` to switch the SDK client to use FIPS endpoints, as an alternative to explicitly declaring them. * Also provides it as a path capability. * This is not a blocker for FIPS support. * SDK itself doesn't know that some places (eu) don't have FIPs endpoints * SDK only fails with endpoint + fips flag as a retried exception; this PR fails fast. * Adds a new "connecting.md" doc; moves existing docs there and restructures. Change-Id: I0a7cc60022f2ee657c8f18ed9ed18f8f66a15567
1 parent 607c981 commit 4edd890

File tree

8 files changed

+574
-251
lines changed

8 files changed

+574
-251
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/Constants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,15 @@ private Constants() {
13351335
*/
13361336
public static final String AWS_S3_DEFAULT_REGION = "us-east-2";
13371337

1338+
/**
1339+
* Is the endpoint a FIPS endpoint?
1340+
* Can be queried as a path capability.
1341+
* Value {@value}.
1342+
*/
1343+
public static final String ENDPOINT_FIPS = "fs.s3a.endpoint.fips";
1344+
1345+
public static final boolean ENDPOINT_FIPS_DEFAULT = false;
1346+
13381347
/**
13391348
* Require that all S3 access is made through Access Points.
13401349
*/

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static org.apache.hadoop.fs.s3a.Constants.DEFAULT_SECURE_CONNECTIONS;
5757
import static org.apache.hadoop.fs.s3a.Constants.SECURE_CONNECTIONS;
5858
import static org.apache.hadoop.fs.s3a.Constants.AWS_SERVICE_IDENTIFIER_S3;
59+
import static org.apache.hadoop.util.Preconditions.checkArgument;
5960

6061

6162
/**
@@ -163,6 +164,8 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> Build
163164
.pathStyleAccessEnabled(parameters.isPathStyleAccess())
164165
.build();
165166

167+
builder.fipsEnabled(parameters.isFipsEnabled());
168+
166169
return builder
167170
.overrideConfiguration(createClientOverrideConfiguration(parameters, conf))
168171
.credentialsProvider(parameters.getCredentialSet())
@@ -229,6 +232,7 @@ protected ClientOverrideConfiguration createClientOverrideConfiguration(
229232
* @param conf conf configuration object
230233
* @param <BuilderT> S3 client builder type
231234
* @param <ClientT> S3 client type
235+
* @throws IllegalArgumentException if endpoint is set when FIPS is enabled.
232236
*/
233237
private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> void configureEndpointAndRegion(
234238
BuilderT builder, S3ClientCreationParameters parameters, Configuration conf) {
@@ -244,7 +248,16 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> void
244248
region = Region.of(configuredRegion);
245249
}
246250

251+
// FIPs? Set it, then reject any attempt to set an endpoint
252+
final boolean fipsEnabled = parameters.isFipsEnabled();
253+
if (fipsEnabled) {
254+
LOG.debug("Enabling FIPS mode");
255+
builder.fipsEnabled(true);
256+
}
257+
247258
if (endpoint != null) {
259+
checkArgument(!fipsEnabled,
260+
"A custom endpoint cannot be combined with FIPS: %s", endpoint);
248261
builder.endpointOverride(endpoint);
249262
// No region was configured, try to determine it from the endpoint.
250263
if (region == null) {

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@ public class S3AFileSystem extends FileSystem implements StreamCapabilities,
461461
*/
462462
private boolean isMultipartCopyEnabled;
463463

464+
/**
465+
* Is FIPS enabled?
466+
*/
467+
private boolean fipsEnabled;
468+
464469
/**
465470
* A cache of files that should be deleted when the FileSystem is closed
466471
* or the JVM is exited.
@@ -614,6 +619,8 @@ public void initialize(URI name, Configuration originalConf)
614619
? conf.getTrimmed(AWS_REGION)
615620
: accessPoint.getRegion();
616621

622+
fipsEnabled = conf.getBoolean(ENDPOINT_FIPS, ENDPOINT_FIPS_DEFAULT);
623+
617624
// is this an S3Express store?
618625
s3ExpressStore = isS3ExpressStore(bucket, endpoint);
619626

@@ -1045,7 +1052,8 @@ private void bindAWSClient(URI name, boolean dtEnabled) throws IOException {
10451052
.withMultipartCopyEnabled(isMultipartCopyEnabled)
10461053
.withMultipartThreshold(multiPartThreshold)
10471054
.withTransferManagerExecutor(unboundedThreadPool)
1048-
.withRegion(configuredRegion);
1055+
.withRegion(configuredRegion)
1056+
.withFipsEnabled(fipsEnabled);
10491057

10501058
S3ClientFactory clientFactory = ReflectionUtils.newInstance(s3ClientFactoryClass, conf);
10511059
s3Client = clientFactory.createS3Client(getUri(), parameters);
@@ -5514,6 +5522,10 @@ public boolean hasPathCapability(final Path path, final String capability)
55145522
case OPTIMIZED_COPY_FROM_LOCAL:
55155523
return optimizedCopyFromLocal;
55165524

5525+
// probe for a fips endpoint
5526+
case ENDPOINT_FIPS:
5527+
return fipsEnabled;
5528+
55175529
default:
55185530
return super.hasPathCapability(p, cap);
55195531
}

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3ClientFactory.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ final class S3ClientCreationParameters {
170170
*/
171171
private String region;
172172

173+
/**
174+
* Is FIPS enabled?
175+
*/
176+
private boolean fipsEnabled;
173177

174178
/**
175179
* List of execution interceptors to include in the chain
@@ -422,5 +426,23 @@ public S3ClientCreationParameters withRegion(
422426
public String getRegion() {
423427
return region;
424428
}
429+
430+
/**
431+
* Get the FIPS flag.
432+
* @return is fips enabled
433+
*/
434+
public boolean isFipsEnabled() {
435+
return fipsEnabled;
436+
}
437+
438+
/**
439+
* Set builder value.
440+
* @param value new value
441+
* @return the builder
442+
*/
443+
public S3ClientCreationParameters withFipsEnabled(final boolean value) {
444+
fipsEnabled = value;
445+
return this;
446+
}
425447
}
426448
}

0 commit comments

Comments
 (0)