This is an automated email from the ASF dual-hosted git repository.

jerryshao pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new 08c8515037 [Cherry-pick to branch-1.3] [#12642] fix(authz): add 
missing supportsScheme to JdbcCredentialProvider (#12644) (#12659)
08c8515037 is described below

commit 08c85150371cddf54c958e9c59eb4afeb6e8b286
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Aug 28 14:04:58 2026 +0800

    [Cherry-pick to branch-1.3] [#12642] fix(authz): add missing supportsScheme 
to JdbcCredentialProvider (#12644) (#12659)
    
    **Cherry-pick Information:**
    - Original commit: 47c617cd6fcfd28709d9f13f783502150388571a
    - Target branch: `branch-1.3`
    - Status: ✅ Clean cherry-pick (no conflicts)
    
    Co-authored-by: Valverde <[email protected]>
    Co-authored-by: Valverde <[email protected]>
    Co-authored-by: Qi Yu <[email protected]>
---
 .../credential/JdbcCredentialProvider.java         |  5 ++
 .../credential/TestCatalogCredentialManager.java   | 58 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git 
a/core/src/main/java/org/apache/gravitino/credential/JdbcCredentialProvider.java
 
b/core/src/main/java/org/apache/gravitino/credential/JdbcCredentialProvider.java
index 0eeee58cfb..2a7ff7437e 100644
--- 
a/core/src/main/java/org/apache/gravitino/credential/JdbcCredentialProvider.java
+++ 
b/core/src/main/java/org/apache/gravitino/credential/JdbcCredentialProvider.java
@@ -50,6 +50,11 @@ public class JdbcCredentialProvider implements 
CredentialProvider {
     return JdbcCredential.JDBC_CREDENTIAL_TYPE;
   }
 
+  @Override
+  public boolean supportsScheme(String scheme) {
+    return "jdbc".equalsIgnoreCase(scheme);
+  }
+
   @Nullable
   @Override
   public Credential getCredential(CredentialContext context) {
diff --git 
a/core/src/test/java/org/apache/gravitino/credential/TestCatalogCredentialManager.java
 
b/core/src/test/java/org/apache/gravitino/credential/TestCatalogCredentialManager.java
new file mode 100644
index 0000000000..88f4bc6404
--- /dev/null
+++ 
b/core/src/test/java/org/apache/gravitino/credential/TestCatalogCredentialManager.java
@@ -0,0 +1,58 @@
+/*
+ *  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 com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.Map;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestCatalogCredentialManager {
+
+  @Test
+  void testSelectsStorageCredentialWhenJdbcProviderIsAlsoConfigured() {
+    String s3Path = "s3://bucket/warehouse/table";
+    Map<String, String> catalogProperties =
+        ImmutableMap.of(
+            CredentialConstants.CREDENTIAL_PROVIDERS,
+            String.join(
+                ",", DummyCredentialProvider.CREDENTIAL_TYPE, 
JdbcCredential.JDBC_CREDENTIAL_TYPE),
+            JdbcCredential.GRAVITINO_JDBC_USER,
+            "test-user",
+            JdbcCredential.GRAVITINO_JDBC_PASSWORD,
+            "test-password");
+
+    try (CatalogCredentialManager credentialManager =
+        new CatalogCredentialManager("test-catalog", catalogProperties)) {
+      PathBasedCredentialContext context =
+          new PathBasedCredentialContext("test-user", ImmutableSet.of(), 
ImmutableSet.of(s3Path));
+
+      Credential credential =
+          credentialManager
+              .getCredentialByPath(s3Path, context)
+              .orElseThrow(() -> new AssertionError("Expected a storage 
credential"));
+
+      
Assertions.assertInstanceOf(DummyCredentialProvider.DummyCredential.class, 
credential);
+      Assertions.assertTrue(
+          
credentialManager.getCredentialProvider(JdbcCredential.JDBC_CREDENTIAL_TYPE).isPresent());
+    }
+  }
+}

Reply via email to