singhpk234 commented on code in PR #3327:
URL: https://github.com/apache/polaris/pull/3327#discussion_r2656025721


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/aws/AwsSessionTagsBuilder.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.core.storage.aws;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.polaris.core.auth.PolarisPrincipal;
+import org.apache.polaris.core.storage.CredentialVendingContext;
+import software.amazon.awssdk.services.sts.model.Tag;
+
+/**
+ * Utility class for building AWS STS session tags from credential vending 
context. These tags
+ * appear in CloudTrail events for correlation between catalog operations and 
S3 data access.
+ */
+public final class AwsSessionTagsBuilder {
+
+  // AWS limit for session tag values
+  static final int MAX_TAG_VALUE_LENGTH = 256;
+
+  /** Placeholder value used when a tag value is null or empty. */
+  static final String TAG_VALUE_UNKNOWN = "unknown";
+
+  private AwsSessionTagsBuilder() {
+    // Utility class - prevent instantiation
+  }
+
+  /**
+   * Builds a list of AWS STS session tags from the principal and credential 
vending context. These
+   * tags will appear in CloudTrail events for correlation purposes.
+   *
+   * @param principal the principal requesting credentials (provides name and 
activated roles)
+   * @param context the credential vending context containing catalog, 
namespace, and table
+   * @return a list of STS Tags to attach to the AssumeRole request
+   */
+  public static List<Tag> buildSessionTags(
+      PolarisPrincipal principal, CredentialVendingContext context) {
+    List<Tag> tags = new ArrayList<>();
+
+    // Extract principal name and roles
+    String principalName = principal.getName();
+    Set<String> roles = principal.getRoles();

Review Comment:
   GRANTs are done on roles and which is later used to infer the R/W location, 
nevertheless the CredentialVendingContext i think is added to the cache key 
right so roles becomes part of cache key ? i believe the existing cache will be 
cleared as soon as this changes are deployed since its in memory. I don't fully 
get the concern though.
   
   Agree with @dimas-b we can have this discussion in a dedicated PR and work 
through it together, at this point fine with reverting :) 



-- 
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