adutra commented on code in PR #2280:
URL: https://github.com/apache/polaris/pull/2280#discussion_r2260480360


##########
runtime/service/src/main/java/org/apache/polaris/service/storage/aws/signer/S3RequestSignerImpl.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.storage.aws.signer;
+
+import java.net.URI;
+import java.util.Set;
+import org.apache.iceberg.aws.s3.signer.ImmutableS3SignResponse;
+import org.apache.iceberg.aws.s3.signer.S3SignResponse;
+import org.apache.polaris.core.config.RealmConfig;
+import org.apache.polaris.core.storage.AccessConfig;
+import org.apache.polaris.core.storage.StorageAccessProperty;
+import org.apache.polaris.core.storage.aws.AwsCredentialsStorageIntegration;
+import org.apache.polaris.core.storage.aws.AwsStorageConfigurationInfo;
+import org.apache.polaris.core.storage.cache.StorageCredentialCache;
+import org.apache.polaris.service.types.S3SignRequest;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
+import software.amazon.awssdk.http.ContentStreamProvider;
+import software.amazon.awssdk.http.SdkHttpFullRequest;
+import software.amazon.awssdk.http.SdkHttpMethod;
+import software.amazon.awssdk.http.SdkHttpRequest;
+import software.amazon.awssdk.http.auth.aws.signer.AwsV4HttpSigner;
+import software.amazon.awssdk.http.auth.spi.signer.SignRequest;
+import software.amazon.awssdk.http.auth.spi.signer.SignedRequest;
+import software.amazon.awssdk.services.s3.S3Client;
+
+/**
+ * S3 request signer that creates presigned URLs for S3 operations using AWS 
credentials obtained
+ * from the storage integration.
+ */
+public class S3RequestSignerImpl implements S3RequestSigner {
+
+  private final AwsV4HttpSigner signer = AwsV4HttpSigner.create();
+
+  private final AwsCredentialsStorageIntegration storageIntegration;
+  private final StorageCredentialCache storageCredentialCache;
+
+  public S3RequestSignerImpl(
+      AwsCredentialsStorageIntegration storageIntegration,
+      StorageCredentialCache storageCredentialCache) {
+    this.storageIntegration = storageIntegration;
+    this.storageCredentialCache = storageCredentialCache;
+  }
+
+  @Override
+  public S3SignResponse signRequest(
+      RealmConfig realmConfig,
+      AwsStorageConfigurationInfo storageConfig,
+      S3SignRequest signingRequest) {
+
+    SdkHttpMethod method = SdkHttpMethod.valueOf(signingRequest.method());
+    URI uri = signingRequest.uri();
+    String body = signingRequest.body();
+
+    SdkHttpFullRequest.Builder requestToSign =
+        SdkHttpFullRequest.builder()
+            .uri(uri)
+            .protocol(uri.getScheme())
+            .method(method)
+            .headers(signingRequest.headers());
+
+    // FIXME is this correct?
+    boolean allowListOperation = isReadMethod(method);
+    Set<String> allowedReadLocations = isReadMethod(method) ? 
Set.of(uri.toString()) : Set.of();
+    Set<String> allowedWriteLocations = isWriteMethod(method) ? 
Set.of(uri.toString()) : Set.of();
+
+    // TODO use the storageCredentialCache to get or generate subscoped 
credentials

Review Comment:
   Yep I gave up on the idea, the code has changed significantly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to