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

[#6031] extend S3 credential provider to support S3 fileset operations #6033

Merged
merged 1 commit into from
Jan 2, 2025
Merged
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 @@ -20,6 +20,7 @@
package org.apache.gravitino.s3.credential;

import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -49,6 +50,7 @@

/** Generates S3 token to access S3 data. */
public class S3TokenProvider implements CredentialProvider {

private StsClient stsClient;
private String roleArn;
private String externalID;
Expand Down Expand Up @@ -134,6 +136,7 @@ private IamPolicy createPolicy(
allowGetObjectStatementBuilder.addResource(
IamResource.create(getS3UriWithArn(arnPrefix, uri)));
String bucketArn = arnPrefix + getBucketName(uri);
String rawPath = trimLeadingSlash(uri.getPath());
bucketListStatmentBuilder
.computeIfAbsent(
bucketArn,
Expand All @@ -142,10 +145,14 @@ private IamPolicy createPolicy(
.effect(IamEffect.ALLOW)
.addAction("s3:ListBucket")
.addResource(key))
.addCondition(
.addConditions(
IamConditionOperator.STRING_LIKE,
"s3:prefix",
concatPathWithSep(trimLeadingSlash(uri.getPath()), "*", "/"));
Arrays.asList(
// Get raw path metadata information for AWS hadoop connector
rawPath,
// Listing objects in raw path
concatPathWithSep(rawPath, "*", "/")));
bucketGetLocationStatmentBuilder.computeIfAbsent(
bucketArn,
key ->
Expand Down
Loading