roryqi commented on code in PR #13987:
URL: https://github.com/apache/gravitino/pull/13987#discussion_r4334393426


##########
common/src/main/java/org/apache/gravitino/credential/RoleSessionNameUtils.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.gravitino.credential;
+
+import java.nio.charset.StandardCharsets;
+import java.util.UUID;
+
+/** Builds cloud STS role session names from arbitrary user names. */
+public final class RoleSessionNameUtils {
+  private static final int MAX_LENGTH = 64;
+
+  private RoleSessionNameUtils() {}
+
+  /**
+   * Builds an ASCII session name with a stable suffix identifying the 
original user.
+   *
+   * @param prefix the provider's session name prefix
+   * @param userName the authenticated user name
+   * @return a session name accepted by AWS and Aliyun STS
+   */
+  public static String create(String prefix, String userName) {
+    String suffix =
+        "_"
+            + UUID.nameUUIDFromBytes(userName.getBytes(StandardCharsets.UTF_8))
+                .toString()
+                .substring(0, 16);
+    String cleaned = userName.replaceAll("[^A-Za-z0-9_+=,.@-]", "_");

Review Comment:
   Fixed in 890d7385ea. RoleSessionNameUtils now keeps only characters accepted 
by both AWS and Aliyun, replacing +, =, and , with _. I added a regression test 
for all three characters and updated the allowed-character assertion. The 
focused common test passed. Thanks for catching this.



##########
bundles/azure/src/main/java/org/apache/gravitino/abs/credential/ADLSTokenGenerator.java:
##########
@@ -175,6 +176,20 @@ && isDescendantOf(location, possibleParent)))
     return rootLocations.get(0);
   }
 
+  private static ADLSLocationUtils.ADLSLocationParts 
parseSupportedLocation(String path) {
+    URI uri = URI.create(path);
+    if (!"abfs".equalsIgnoreCase(uri.getScheme()) && 
!"abfss".equalsIgnoreCase(uri.getScheme())) {
+      throw new IllegalArgumentException(

Review Comment:
   Fixed in 890d7385ea. CredentialProviderDelegator now preserves 
IllegalArgumentException from path validation, so callers receive the ADLS 
location and abfs/abfss guidance. I added a provider test for the wasbs path 
and a credential REST test asserting a 400 response with that guidance. The 
focused Azure and server tests passed. Thanks for pointing out the lost 
diagnostic.



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