yuqi1129 commented on code in PR #13987:
URL: https://github.com/apache/gravitino/pull/13987#discussion_r4333843838
##########
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:
[Nit] The early rejection is appropriate, but the clear unsupported-location
message does not currently reach callers as claimed in the PR description.
CredentialProviderDelegator.getCredential catches this exception and wraps it
with `Failed to generate credential using ...`; the credential REST handler
then returns a generic 500, and the Iceberg REST mapper also uses the wrapper
message. The original cause remains in server logs, but callers lose the
location and the guidance to use abfs/abfss. Could we preserve this validation
error at the provider/REST boundary and cover the externally visible response?
This wrapping behavior predates the PR, so I consider this a non-blocking
diagnostic improvement.
##########
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:
[Important] This character set is valid for AWS, but Aliyun RoleSessionName
only allows letters, digits, and `._@-`
(https://www.alibabacloud.com/help/en/ram/developer-reference/api-sts-2015-04-01-assumerole).
The helper preserves `+`, `=`, and `,`, and OSSTokenGenerator passes the
result directly to STS. For example, I ran this helper with
`[email protected]` and obtained
`[email protected]_329ae947-e59e-3b`, which still violates the
Aliyun constraint and can prevent OSS credential vending. Could we use the
intersection of the supported character sets, or make sanitization
provider-specific, and add cases for these three characters? The current test
checks the AWS regex, so it misses this remaining gap in the intended fix.
--
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]