You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by yu...@apache.org on 2026/06/23 13:35:04 UTC
(gravitino) branch fileset-hide-credential-properties-11642 created (now 9542feee51)
This is an automated email from the ASF dual-hosted git repository.
yuqi1129 pushed a change to branch fileset-hide-credential-properties-11642
in repository https://gitbox.apache.org/repos/asf/gravitino.git
at 9542feee51 [#11642] improvement(gvfs): make credential vending and client credentials mutually exclusive
This branch includes the following new commits:
new 9542feee51 [#11642] improvement(gvfs): make credential vending and client credentials mutually exclusive
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(gravitino) 01/01: [#11642] improvement(gvfs): make credential vending and client credentials mutually exclusive
Posted by yu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
yuqi1129 pushed a commit to branch fileset-hide-credential-properties-11642
in repository https://gitbox.apache.org/repos/asf/gravitino.git
commit 9542feee519e7f9cf5767d1948c35057ad5222ef
Author: yuqi <yu...@datastrato.com>
AuthorDate: Tue Jun 23 21:34:53 2026 +0800
[#11642] improvement(gvfs): make credential vending and client credentials mutually exclusive
Credential vending and client-configured storage credentials are now
mutually exclusive, controlled solely by enableCredentialVending:
- enabled: the server-vended credentials are authoritative and always
take effect; any client-configured storage credentials are ignored.
- disabled (default): the client must configure its own storage
credentials, otherwise storage access fails.
This removes the previous client-credential detection gate
(SupportsCredentialVending#containsClientCredentials and the Python
StorageHandler.contains_client_credentials), which decided precedence by
sniffing client config. That detection was inherently incomplete (it only
recognized the static access-key/secret-key form and missed other
client-provided credential forms), so precedence is now decided by an
explicit flag instead.
- Java: BaseGVFSOperations vends unconditionally when enabled; drop the
gate and the per-provider overrides (S3/OSS/GCS/Azure) plus allNonBlank.
- Python: gvfs_base_operations vends when enabled; drop
contains_client_credentials and _all_non_blank from the storage handlers.
- Docs: document the mutual-exclusivity contract in how-to-use-gvfs.md
and credential-vending.md.
- Tests: remove obsolete gate unit tests; add an IT (Java + Python)
asserting vended credentials take precedence even when invalid client
credentials are also configured.
---
.../gravitino/oss/fs/OSSFileSystemProvider.java | 8 ---
.../oss/fs/TestOSSFileSystemProvider.java | 48 --------------
.../gravitino/s3/fs/S3FileSystemProvider.java | 8 ---
.../gravitino/s3/fs/TestS3FileSystemProvider.java | 48 --------------
.../gravitino/abs/fs/AzureFileSystemProvider.java | 8 ---
.../abs/fs/TestAzureFileSystemProvider.java | 45 -------------
.../gravitino/gcs/fs/GCSFileSystemProvider.java | 6 --
.../gcs/fs/TestGCSFileSystemProvider.java | 41 ------------
.../hadoop/fs/SupportsCredentialVending.java | 33 ----------
.../hadoop/fs/TestSupportsCredentialVending.java | 60 -----------------
.../gravitino/filesystem/gvfs_base_operations.py | 11 ++--
.../gravitino/filesystem/gvfs_storage_handler.py | 41 ------------
.../integration/test_gvfs_with_s3_credential.py | 22 +++++++
.../tests/unittests/test_storage_handler.py | 54 ----------------
.../filesystem/hadoop/BaseGVFSOperations.java | 24 +------
.../test/GravitinoVirtualFileSystemS3IT.java | 75 ++++++++++++++++++++++
docs/how-to-use-gvfs.md | 4 +-
docs/security/credential-vending.md | 9 +++
18 files changed, 115 insertions(+), 430 deletions(-)
diff --git a/bundles/aliyun/src/main/java/org/apache/gravitino/oss/fs/OSSFileSystemProvider.java b/bundles/aliyun/src/main/java/org/apache/gravitino/oss/fs/OSSFileSystemProvider.java
index c3e9a2bfc7..0f443dbcf2 100644
--- a/bundles/aliyun/src/main/java/org/apache/gravitino/oss/fs/OSSFileSystemProvider.java
+++ b/bundles/aliyun/src/main/java/org/apache/gravitino/oss/fs/OSSFileSystemProvider.java
@@ -87,14 +87,6 @@ public class OSSFileSystemProvider implements FileSystemProvider, SupportsCreden
return result;
}
- @Override
- public boolean containsClientCredentials(Map<String, String> config) {
- return SupportsCredentialVending.allNonBlank(
- config,
- OSSProperties.GRAVITINO_OSS_ACCESS_KEY_ID,
- OSSProperties.GRAVITINO_OSS_ACCESS_KEY_SECRET);
- }
-
@Override
public String scheme() {
return "oss";
diff --git a/bundles/aliyun/src/test/java/org/apache/gravitino/oss/fs/TestOSSFileSystemProvider.java b/bundles/aliyun/src/test/java/org/apache/gravitino/oss/fs/TestOSSFileSystemProvider.java
deleted file mode 100644
index c07b64225b..0000000000
--- a/bundles/aliyun/src/test/java/org/apache/gravitino/oss/fs/TestOSSFileSystemProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.oss.fs;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.gravitino.storage.OSSProperties;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestOSSFileSystemProvider {
-
- private final OSSFileSystemProvider provider = new OSSFileSystemProvider();
-
- @Test
- public void testContainsClientCredentialsTrueWhenBothKeysPresent() {
- Assertions.assertTrue(
- provider.containsClientCredentials(
- ImmutableMap.of(
- OSSProperties.GRAVITINO_OSS_ACCESS_KEY_ID, "ak",
- OSSProperties.GRAVITINO_OSS_ACCESS_KEY_SECRET, "sk")));
- }
-
- @Test
- public void testContainsClientCredentialsFalseWhenIncomplete() {
- Assertions.assertFalse(
- provider.containsClientCredentials(
- ImmutableMap.of(OSSProperties.GRAVITINO_OSS_ACCESS_KEY_ID, "ak")));
- Assertions.assertFalse(
- provider.containsClientCredentials(
- ImmutableMap.of(OSSProperties.GRAVITINO_OSS_ENDPOINT, "endpoint")));
- }
-}
diff --git a/bundles/aws/src/main/java/org/apache/gravitino/s3/fs/S3FileSystemProvider.java b/bundles/aws/src/main/java/org/apache/gravitino/s3/fs/S3FileSystemProvider.java
index 62654bcac5..07cf221d74 100644
--- a/bundles/aws/src/main/java/org/apache/gravitino/s3/fs/S3FileSystemProvider.java
+++ b/bundles/aws/src/main/java/org/apache/gravitino/s3/fs/S3FileSystemProvider.java
@@ -101,14 +101,6 @@ public class S3FileSystemProvider implements FileSystemProvider, SupportsCredent
return result;
}
- @Override
- public boolean containsClientCredentials(Map<String, String> config) {
- return SupportsCredentialVending.allNonBlank(
- config,
- S3Properties.GRAVITINO_S3_ACCESS_KEY_ID,
- S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY);
- }
-
private void checkAndSetCredentialProvider(Map<String, String> configs) {
String provides = configs.get(S3_CREDENTIAL_KEY);
if (provides == null) {
diff --git a/bundles/aws/src/test/java/org/apache/gravitino/s3/fs/TestS3FileSystemProvider.java b/bundles/aws/src/test/java/org/apache/gravitino/s3/fs/TestS3FileSystemProvider.java
deleted file mode 100644
index 4654275bdd..0000000000
--- a/bundles/aws/src/test/java/org/apache/gravitino/s3/fs/TestS3FileSystemProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.s3.fs;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.gravitino.storage.S3Properties;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestS3FileSystemProvider {
-
- private final S3FileSystemProvider provider = new S3FileSystemProvider();
-
- @Test
- public void testContainsClientCredentialsTrueWhenBothKeysPresent() {
- Assertions.assertTrue(
- provider.containsClientCredentials(
- ImmutableMap.of(
- S3Properties.GRAVITINO_S3_ACCESS_KEY_ID, "ak",
- S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY, "sk")));
- }
-
- @Test
- public void testContainsClientCredentialsFalseWhenIncomplete() {
- Assertions.assertFalse(
- provider.containsClientCredentials(
- ImmutableMap.of(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID, "ak")));
- Assertions.assertFalse(
- provider.containsClientCredentials(
- ImmutableMap.of(S3Properties.GRAVITINO_S3_ENDPOINT, "endpoint")));
- }
-}
diff --git a/bundles/azure/src/main/java/org/apache/gravitino/abs/fs/AzureFileSystemProvider.java b/bundles/azure/src/main/java/org/apache/gravitino/abs/fs/AzureFileSystemProvider.java
index 1b6f71f99b..08d780c09f 100644
--- a/bundles/azure/src/main/java/org/apache/gravitino/abs/fs/AzureFileSystemProvider.java
+++ b/bundles/azure/src/main/java/org/apache/gravitino/abs/fs/AzureFileSystemProvider.java
@@ -115,14 +115,6 @@ public class AzureFileSystemProvider implements FileSystemProvider, SupportsCred
return ABS_PROVIDER_NAME;
}
- @Override
- public boolean containsClientCredentials(Map<String, String> config) {
- return SupportsCredentialVending.allNonBlank(
- config,
- AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME,
- AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY);
- }
-
/**
* Add additional Azure specific configuration to tune the performance.
*
diff --git a/bundles/azure/src/test/java/org/apache/gravitino/abs/fs/TestAzureFileSystemProvider.java b/bundles/azure/src/test/java/org/apache/gravitino/abs/fs/TestAzureFileSystemProvider.java
deleted file mode 100644
index b2833ce7a3..0000000000
--- a/bundles/azure/src/test/java/org/apache/gravitino/abs/fs/TestAzureFileSystemProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.abs.fs;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.gravitino.storage.AzureProperties;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestAzureFileSystemProvider {
-
- private final AzureFileSystemProvider provider = new AzureFileSystemProvider();
-
- @Test
- public void testContainsClientCredentialsTrueWhenBothKeysPresent() {
- Assertions.assertTrue(
- provider.containsClientCredentials(
- ImmutableMap.of(
- AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME, "name",
- AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY, "key")));
- }
-
- @Test
- public void testContainsClientCredentialsFalseWhenIncomplete() {
- Assertions.assertFalse(
- provider.containsClientCredentials(
- ImmutableMap.of(AzureProperties.GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME, "name")));
- }
-}
diff --git a/bundles/gcp/src/main/java/org/apache/gravitino/gcs/fs/GCSFileSystemProvider.java b/bundles/gcp/src/main/java/org/apache/gravitino/gcs/fs/GCSFileSystemProvider.java
index 51f1c847bf..ac62d43331 100644
--- a/bundles/gcp/src/main/java/org/apache/gravitino/gcs/fs/GCSFileSystemProvider.java
+++ b/bundles/gcp/src/main/java/org/apache/gravitino/gcs/fs/GCSFileSystemProvider.java
@@ -69,12 +69,6 @@ public class GCSFileSystemProvider implements FileSystemProvider, SupportsCreden
return result;
}
- @Override
- public boolean containsClientCredentials(Map<String, String> config) {
- return SupportsCredentialVending.allNonBlank(
- config, GCSProperties.GRAVITINO_GCS_SERVICE_ACCOUNT_FILE);
- }
-
@Override
public String scheme() {
return "gs";
diff --git a/bundles/gcp/src/test/java/org/apache/gravitino/gcs/fs/TestGCSFileSystemProvider.java b/bundles/gcp/src/test/java/org/apache/gravitino/gcs/fs/TestGCSFileSystemProvider.java
deleted file mode 100644
index 8d4fc54391..0000000000
--- a/bundles/gcp/src/test/java/org/apache/gravitino/gcs/fs/TestGCSFileSystemProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.gcs.fs;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.gravitino.storage.GCSProperties;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestGCSFileSystemProvider {
-
- private final GCSFileSystemProvider provider = new GCSFileSystemProvider();
-
- @Test
- public void testContainsClientCredentialsTrueWhenServiceAccountFilePresent() {
- Assertions.assertTrue(
- provider.containsClientCredentials(
- ImmutableMap.of(GCSProperties.GRAVITINO_GCS_SERVICE_ACCOUNT_FILE, "/path/to/file")));
- }
-
- @Test
- public void testContainsClientCredentialsFalseWhenAbsent() {
- Assertions.assertFalse(provider.containsClientCredentials(ImmutableMap.of("other", "value")));
- }
-}
diff --git a/catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/SupportsCredentialVending.java b/catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/SupportsCredentialVending.java
index 30f95ddaa7..a9c0b688d0 100644
--- a/catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/SupportsCredentialVending.java
+++ b/catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/SupportsCredentialVending.java
@@ -34,37 +34,4 @@ public interface SupportsCredentialVending {
default Map<String, String> getFileSystemCredentialConf(Credential[] credentials) {
return ImmutableMap.of();
}
-
- /**
- * Whether the given configuration already contains client-provided static storage credentials
- * (e.g. {@code s3-access-key-id}/{@code s3-secret-access-key}). When the client configures its
- * own credentials, they must take precedence over server-side vended credentials, so callers
- * should skip credential vending in that case.
- *
- * @param config the merged file system configuration
- * @return true if the client supplied its own storage credentials, false otherwise
- */
- default boolean containsClientCredentials(Map<String, String> config) {
- return false;
- }
-
- /**
- * Returns whether all of the given keys are present in the configuration with a non-blank value.
- *
- * @param config the configuration to inspect
- * @param keys the keys that must all be present and non-blank
- * @return true if every key is present with a non-blank value, false otherwise
- */
- static boolean allNonBlank(Map<String, String> config, String... keys) {
- if (config == null) {
- return false;
- }
- for (String key : keys) {
- String value = config.get(key);
- if (value == null || value.trim().isEmpty()) {
- return false;
- }
- }
- return true;
- }
}
diff --git a/catalogs/hadoop-common/src/test/java/org/apache/gravitino/catalog/hadoop/fs/TestSupportsCredentialVending.java b/catalogs/hadoop-common/src/test/java/org/apache/gravitino/catalog/hadoop/fs/TestSupportsCredentialVending.java
deleted file mode 100644
index cd7caf04d5..0000000000
--- a/catalogs/hadoop-common/src/test/java/org/apache/gravitino/catalog/hadoop/fs/TestSupportsCredentialVending.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.catalog.hadoop.fs;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestSupportsCredentialVending {
-
- @Test
- public void testAllNonBlankTrueWhenAllPresent() {
- Map<String, String> config = ImmutableMap.of("ak", "id", "sk", "secret");
- Assertions.assertTrue(SupportsCredentialVending.allNonBlank(config, "ak", "sk"));
- }
-
- @Test
- public void testAllNonBlankFalseWhenMissingKey() {
- Map<String, String> config = ImmutableMap.of("ak", "id");
- Assertions.assertFalse(SupportsCredentialVending.allNonBlank(config, "ak", "sk"));
- }
-
- @Test
- public void testAllNonBlankFalseWhenBlankValue() {
- Map<String, String> config = new HashMap<>();
- config.put("ak", "id");
- config.put("sk", " ");
- Assertions.assertFalse(SupportsCredentialVending.allNonBlank(config, "ak", "sk"));
- }
-
- @Test
- public void testAllNonBlankFalseWhenNullConfig() {
- Assertions.assertFalse(SupportsCredentialVending.allNonBlank(null, "ak"));
- }
-
- @Test
- public void testDefaultContainsClientCredentialsIsFalse() {
- SupportsCredentialVending vending = new SupportsCredentialVending() {};
- Assertions.assertFalse(vending.containsClientCredentials(ImmutableMap.of("ak", "id")));
- }
-}
diff --git a/clients/client-python/gravitino/filesystem/gvfs_base_operations.py b/clients/client-python/gravitino/filesystem/gvfs_base_operations.py
index dd13436c94..cca470b197 100644
--- a/clients/client-python/gravitino/filesystem/gvfs_base_operations.py
+++ b/clients/client-python/gravitino/filesystem/gvfs_base_operations.py
@@ -571,14 +571,11 @@ class BaseGVFSOperations(ABC):
CallerContextHolder.set(caller_context)
try:
- # Credentials are only fetched when credential vending is enabled. Client-provided
- # credentials take precedence over server-side vended credentials, so skip vending when
- # the client already configured its own storage credentials; otherwise the vended
- # credentials would override the client's credentials.
+ # Credentials are only fetched when credential vending is enabled. Credential vending and
+ # client-configured storage credentials are mutually exclusive: when vending is enabled
+ # the server-vended credentials are authoritative.
credentials = None
- if self._enable_credential_vending and not get_storage_handler_by_path(
- actual_location
- ).contains_client_credentials(fileset_props):
+ if self._enable_credential_vending:
# Get credentials with client-side caching to avoid redundant REST calls
credentials = self._get_credentials_with_cache(
fileset_ident, fileset, target_location_name
diff --git a/clients/client-python/gravitino/filesystem/gvfs_storage_handler.py b/clients/client-python/gravitino/filesystem/gvfs_storage_handler.py
index b61edf9058..22abc27aa9 100644
--- a/clients/client-python/gravitino/filesystem/gvfs_storage_handler.py
+++ b/clients/client-python/gravitino/filesystem/gvfs_storage_handler.py
@@ -98,21 +98,6 @@ class StorageHandler(ABC):
"""
pass
- def contains_client_credentials(self, props: Dict[str, str]) -> bool:
- """Whether the given properties already contain client-provided static storage
- credentials. When the client configures its own credentials, they must take precedence
- over server-side vended credentials, so the caller should skip credential vending.
-
- :param props: The merged fileset properties (including client options)
- :return: True if the client supplied its own storage credentials, False otherwise
- """
- return False
-
- @staticmethod
- def _all_non_blank(props: Dict[str, str], *keys: str) -> bool:
- """Return whether all of the given keys are present in props with a non-blank value."""
- return all(props.get(key) not in (None, "") for key in keys)
-
def actual_info_to_gvfs_info(
self,
entry: Dict,
@@ -374,13 +359,6 @@ class S3StorageHandler(StorageHandler):
),
)
- def contains_client_credentials(self, props: Dict[str, str]) -> bool:
- return self._all_non_blank(
- props,
- GVFSConfig.GVFS_FILESYSTEM_S3_ACCESS_KEY,
- GVFSConfig.GVFS_FILESYSTEM_S3_SECRET_KEY,
- )
-
def get_filesystem(
self, actual_path: Optional[str] = None, **kwargs
) -> AbstractFileSystem:
@@ -414,11 +392,6 @@ class GCSStorageHandler(StorageHandler):
def storage_type(self):
return StorageType.GCS
- def contains_client_credentials(self, props: Dict[str, str]) -> bool:
- return self._all_non_blank(
- props, GVFSConfig.GVFS_FILESYSTEM_GCS_SERVICE_KEY_FILE
- )
-
def get_filesystem(
self, actual_path: Optional[str] = None, **kwargs
) -> AbstractFileSystem:
@@ -533,13 +506,6 @@ class OSSStorageHandler(StorageHandler):
return path[len(f"{self.storage_type().value}://") :]
return path
- def contains_client_credentials(self, props: Dict[str, str]) -> bool:
- return self._all_non_blank(
- props,
- GVFSConfig.GVFS_FILESYSTEM_OSS_ACCESS_KEY,
- GVFSConfig.GVFS_FILESYSTEM_OSS_SECRET_KEY,
- )
-
def get_filesystem(
self, actual_path: Optional[str] = None, **kwargs
) -> AbstractFileSystem:
@@ -644,13 +610,6 @@ class ABSStorageHandler(StorageHandler):
def storage_type(self):
return StorageType.ABS
- def contains_client_credentials(self, props: Dict[str, str]) -> bool:
- return self._all_non_blank(
- props,
- GVFSConfig.GVFS_FILESYSTEM_AZURE_ACCOUNT_NAME,
- GVFSConfig.GVFS_FILESYSTEM_AZURE_ACCOUNT_KEY,
- )
-
def get_filesystem(
self, actual_path: Optional[str] = None, **kwargs
) -> AbstractFileSystem:
diff --git a/clients/client-python/tests/integration/test_gvfs_with_s3_credential.py b/clients/client-python/tests/integration/test_gvfs_with_s3_credential.py
index 6841493d83..a2a3034dc6 100644
--- a/clients/client-python/tests/integration/test_gvfs_with_s3_credential.py
+++ b/clients/client-python/tests/integration/test_gvfs_with_s3_credential.py
@@ -176,3 +176,25 @@ class TestGvfsWithS3Credential(TestGvfsWithS3):
# it actually takes no effect.
self.check_mkdir(mkdir_dir, mkdir_actual_dir, fs)
+
+ def test_credential_vending_precedence_over_client_credentials(self):
+ # Credential vending and client-configured storage credentials are mutually exclusive: when
+ # vending is enabled, the server-vended credentials take precedence. Configure deliberately
+ # invalid client credentials together with vending enabled; the write must still succeed
+ # because the vended credentials are used instead of the client-provided ones.
+ options = {
+ f"{GVFSConfig.GVFS_FILESYSTEM_S3_ACCESS_KEY}": "invalid-access-key",
+ f"{GVFSConfig.GVFS_FILESYSTEM_S3_SECRET_KEY}": "invalid-secret-key",
+ f"{GVFSConfig.GVFS_FILESYSTEM_S3_ENDPOINT}": self.s3_endpoint,
+ GVFSConfig.GVFS_FILESYSTEM_ENABLE_CREDENTIAL_VENDING: True,
+ }
+ fs = gvfs.GravitinoVirtualFileSystem(
+ server_uri="http://localhost:8090",
+ metalake_name=self.metalake_name,
+ options=options,
+ **self.conf,
+ )
+ file_path = self.fileset_gvfs_location + "/test_precedence/test.txt"
+ fs.touch(file_path)
+ self.assertTrue(fs.exists(file_path))
+ fs.rm(file_path)
diff --git a/clients/client-python/tests/unittests/test_storage_handler.py b/clients/client-python/tests/unittests/test_storage_handler.py
index 3948f61a93..9e9fdd747d 100644
--- a/clients/client-python/tests/unittests/test_storage_handler.py
+++ b/clients/client-python/tests/unittests/test_storage_handler.py
@@ -21,9 +21,6 @@ from unittest.mock import patch
from fsspec.implementations.memory import MemoryFileSystem
from gravitino.filesystem.gvfs_storage_handler import (
- ABSStorageHandler,
- GCSStorageHandler,
- OSSStorageHandler,
S3StorageHandler,
)
@@ -89,54 +86,3 @@ class TestStorageHandler(unittest.TestCase):
self.assertEqual(captured_args["key"], "access_key_from_client")
self.assertEqual(captured_args["secret"], "secret_key_from_client")
self.assertEqual(captured_args["endpoint_url"], "endpoint_from_catalog")
-
- def test_contains_client_credentials(self):
- # S3: both keys required.
- s3_handler = S3StorageHandler()
- self.assertTrue(
- s3_handler.contains_client_credentials(
- {"s3_access_key_id": "ak", "s3_secret_access_key": "sk"}
- )
- )
- self.assertFalse(
- s3_handler.contains_client_credentials({"s3_access_key_id": "ak"})
- )
- self.assertFalse(
- s3_handler.contains_client_credentials({"s3_endpoint": "endpoint"})
- )
-
- # OSS: both keys required.
- oss_handler = OSSStorageHandler()
- self.assertTrue(
- oss_handler.contains_client_credentials(
- {"oss_access_key_id": "ak", "oss_secret_access_key": "sk"}
- )
- )
- self.assertFalse(
- oss_handler.contains_client_credentials({"oss_access_key_id": "ak"})
- )
-
- # GCS: service account file.
- gcs_handler = GCSStorageHandler()
- self.assertTrue(
- gcs_handler.contains_client_credentials(
- {"gcs_service_account_file": "/path/to/file"}
- )
- )
- self.assertFalse(gcs_handler.contains_client_credentials({"other": "value"}))
-
- # ABS: account name + key.
- abs_handler = ABSStorageHandler()
- self.assertTrue(
- abs_handler.contains_client_credentials(
- {
- "azure_storage_account_name": "name",
- "azure_storage_account_key": "key",
- }
- )
- )
- self.assertFalse(
- abs_handler.contains_client_credentials(
- {"azure_storage_account_name": "name"}
- )
- )
diff --git a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
index 94d32b71c1..17b69557fb 100644
--- a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
+++ b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/BaseGVFSOperations.java
@@ -732,14 +732,11 @@ public abstract class BaseGVFSOperations implements Closeable {
targetLocation.toUri(), allProperties, FS_GRAVITINO_PATH_CONFIG_PREFIX));
if (enableCredentialVending()) {
+ // Credential vending and client-configured storage credentials are mutually exclusive: when
+ // vending is enabled the server-vended credentials are authoritative.
FileSystemProvider provider =
getFileSystemProviderByScheme(targetLocation.toUri().getScheme());
- // Client-provided credentials take precedence over server-side vended credentials. Only
- // vend when the client did not configure its own storage credentials; otherwise the vended
- // credential provider would override the client's credentials.
- if (!clientProvidedStorageCredentials(provider, allProperties)) {
- allProperties.putAll(getCredentialProperties(provider, filesetIdent, locationName));
- }
+ allProperties.putAll(getCredentialProperties(provider, filesetIdent, locationName));
}
FileSystem actualFileSystem = getActualFileSystemByPath(targetLocation, allProperties);
@@ -971,21 +968,6 @@ public abstract class BaseGVFSOperations implements Closeable {
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
- /**
- * Returns whether the client already configured its own static storage credentials for the given
- * provider, in which case server-side credential vending must be skipped so the client-provided
- * credentials take precedence.
- *
- * @param provider the file system provider resolved for the target location
- * @param properties the merged properties (including the client configuration)
- * @return true if the client supplied its own credentials, false otherwise
- */
- private boolean clientProvidedStorageCredentials(
- FileSystemProvider provider, Map<String, String> properties) {
- return provider instanceof SupportsCredentialVending
- && ((SupportsCredentialVending) provider).containsClientCredentials(properties);
- }
-
private Map<String, String> getCredentialProperties(
FileSystemProvider fileSystemProvider,
NameIdentifier filesetIdentifier,
diff --git a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemS3IT.java b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemS3IT.java
index 169d416a8f..f15abdf63d 100644
--- a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemS3IT.java
+++ b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/integration/test/GravitinoVirtualFileSystemS3IT.java
@@ -286,6 +286,81 @@ public class GravitinoVirtualFileSystemS3IT extends GravitinoVirtualFileSystemIT
}
}
+ /**
+ * Verifies the mutually-exclusive contract between credential vending and client-configured
+ * storage credentials: when vending is enabled, the server-vended credentials take precedence and
+ * any client-configured static credentials are ignored. The client below enables vending but also
+ * sets deliberately invalid static credentials; access must still succeed because the vended
+ * credentials are used. (Before vending and client credentials became mutually exclusive, the
+ * presence of client credentials would have skipped vending and caused this to fail.)
+ */
+ @Test
+ public void testCredentialVendingTakesPrecedenceOverClientCredentials() throws IOException {
+ String vendingCatalogName = GravitinoITUtils.genRandomName("precedence_catalog");
+ String vendingSchemaName = GravitinoITUtils.genRandomName("precedence_schema");
+ Map<String, String> catalogProps = Maps.newHashMap();
+ catalogProps.put(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID, accessKey);
+ catalogProps.put(S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY, secretKey);
+ catalogProps.put(S3Properties.GRAVITINO_S3_ENDPOINT, s3Endpoint);
+ catalogProps.put(S3Properties.GRAVITINO_S3_PATH_STYLE_ACCESS, "true");
+ catalogProps.put(FILESYSTEM_PROVIDERS, "s3");
+
+ Catalog vendingCatalog =
+ metalake.createCatalog(
+ vendingCatalogName, Catalog.Type.FILESET, "hadoop", "catalog comment", catalogProps);
+ vendingCatalog.asSchemas().createSchema(vendingSchemaName, "schema comment", catalogProps);
+
+ // Use a dedicated bucket so the underlying S3AFileSystem (cached by scheme://authority) is not
+ // shared with the other tests, which would otherwise mix credential sources.
+ String vendingBucket = "precedence-bucket-" + UUID.randomUUID().toString().replace("-", "");
+ gravitinoLocalStackContainer.executeInContainer(
+ "awslocal", "s3", "mb", "s3://" + vendingBucket);
+
+ String filesetName = GravitinoITUtils.genRandomName("precedence_fileset");
+ NameIdentifier filesetIdent = NameIdentifier.of(vendingSchemaName, filesetName);
+ String storageLocation = String.format("s3a://%s/%s", vendingBucket, filesetName);
+ vendingCatalog
+ .asFilesetCatalog()
+ .createFileset(
+ filesetIdent,
+ "fileset comment",
+ Fileset.Type.MANAGED,
+ storageLocation,
+ new HashMap<>());
+
+ // Client GVFS conf: enables credential vending AND also configures deliberately invalid static
+ // credentials. The vended credentials must take precedence, so access still succeeds.
+ Configuration clientConf = new Configuration();
+ clientConf.set(
+ "fs.gvfs.impl", "org.apache.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem");
+ clientConf.set(
+ "fs.AbstractFileSystem.gvfs.impl", "org.apache.gravitino.filesystem.hadoop.Gvfs");
+ clientConf.set("fs.gvfs.impl.disable.cache", "true");
+ clientConf.set("fs.gravitino.server.uri", serverUri);
+ clientConf.set("fs.gravitino.client.metalake", metalakeName);
+ clientConf.setBoolean("fs.gravitino.enableCredentialVending", true);
+ clientConf.set(S3Properties.GRAVITINO_S3_ENDPOINT, s3Endpoint);
+ clientConf.set(S3Properties.GRAVITINO_S3_PATH_STYLE_ACCESS, "true");
+ clientConf.set(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID, "invalid-access-key");
+ clientConf.set(S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY, "invalid-secret-key");
+
+ Path gvfsPath =
+ new Path(
+ String.format(
+ "gvfs://fileset/%s/%s/%s", vendingCatalogName, vendingSchemaName, filesetName));
+ try (FileSystem gvfs = gvfsPath.getFileSystem(clientConf)) {
+ gvfs.mkdirs(gvfsPath);
+ Path createPath = new Path(gvfsPath + "/test_precedence.txt");
+ gvfs.create(createPath).close();
+ Assertions.assertTrue(gvfs.exists(createPath));
+ Assertions.assertTrue(gvfs.getFileStatus(createPath).isFile());
+ } finally {
+ vendingCatalog.asFilesetCatalog().dropFileset(filesetIdent);
+ vendingCatalog.asSchemas().dropSchema(vendingSchemaName, true);
+ metalake.dropCatalog(vendingCatalogName, true);
+ }
+ }
+
@Disabled(
"GCS does not support append, java.io.IOException: The append operation is not supported")
public void testAppend() throws IOException {}
diff --git a/docs/how-to-use-gvfs.md b/docs/how-to-use-gvfs.md
index f0e192601f..e0ba98829f 100644
--- a/docs/how-to-use-gvfs.md
+++ b/docs/how-to-use-gvfs.md
@@ -68,7 +68,7 @@ the path mapping and convert automatically.
| `fs.gravitino.operations.class` | The operations class to provide the FS operations for the Gravitino Virtual File System. Users can extends `BaseGVFSOperations` to implement their own operations and configure the class name in this conf to use custom FS operations. | `org.apache.gravitino.filesystem.hadoop.DefaultGVFSOperations` | No [...]
| `fs.gravitino.hook.class` | The hook class to inject into the <br/>Gravitino Virtual File System. Users can implement their own `GravitinoVirtualFileSystemHook` and configure the class name in this conf to inject custom code. | `org.apache.gravitino.filesystem.hadoop.NoOpHook` | No [...]
| `fs.gravitino.client.request.header.` | The configuration key prefix for the Gravitino client request header. You can set the request header for the Gravitino client. | (none) | No [...]
-| `fs.gravitino.enableCredentialVending` | Whether to enable credential vending for the Gravitino Virtual File System. | `false` | No [...]
+| `fs.gravitino.enableCredentialVending` | Whether to enable credential vending for the Gravitino Virtual File System. Credential vending and client-configured storage credentials are mutually exclusive: when set to `true`, the server-vended credentials are used and any client-configured storage credentials are ignored; when set to `false`, you must configure your own storage credentials on the client, otherwise access will fail. [...]
| `fs.gravitino.client.` | The configuration key prefix for the Gravitino client config. | (none) | No [...]
| `fs.gravitino.filesetMetadataCache.enable` | Whether to cache the fileset, fileset schema or fileset catalog metadata in the Gravitino Virtual File System. Note that this cache causes a side effect: if you modify the fileset or fileset catalog metadata, the client cannot see the latest changes. | `false` | No [...]
| `fs.gravitino.autoCreateLocation` | The configuration key for whether to enable auto-creation of fileset location when the server-side filesystem ops are disabled and the location does not exist. | `true` | No [...]
@@ -425,7 +425,7 @@ to recompile the native libraries like `libhdfs` and others, and completely repl
| `operations_class` | The operations class to provide the FS operations for the Gravitino Virtual File System. Users can extends `BaseGVFSOperations` to implement their own operations and configure the class name in this conf to use custom FS operations. | `gravitino.filesystem.gvfs_default_operations.DefaultGVFSOperations` | No [...]
| `hook_class` | The hook class to inject into the Gravitino Virtual File System. Users can implement their own `GravitinoVirtualFileSystemHook` and configure the class name in this conf to inject custom code. | `gravitino.filesystem.gvfs_hook.NoOpHook` | No [...]
| `client_request_header_` | The configuration key prefix for the Gravitino client request header. You can set the request header for the Gravitino client. | (none) | No [...]
-| `enable_credential_vending` | Whether to enable credential vending for the Gravitino Virtual File System. | `false` | No [...]
+| `enable_credential_vending` | Whether to enable credential vending for the Gravitino Virtual File System. Credential vending and client-configured storage credentials are mutually exclusive: when set to `true`, the server-vended credentials are used and any client-configured storage credentials are ignored; when set to `false`, you must configure your own storage credentials on the client, otherwise access will fail. [...]
| `gvfs_gravitino_client_` | The configuration key prefix for the Gravitino client. You can set the config for the Gravitino client. | (none) | No [...]
| `enable_fileset_metadata_cache` | Whether to cache the fileset or fileset catalog metadata in the Gravitino Virtual File System. Note that this cache causes a side effect: if you modify the fileset or fileset catalog metadata, the client cannot see the latest changes. | `false` | No [...]
| `auto_create_location` | The configuration key for whether to enable auto-creation of fileset location when the server-side filesystem ops are disabled and the location does not exist. | `true` | No [...]
diff --git a/docs/security/credential-vending.md b/docs/security/credential-vending.md
index 1df065d12e..1d250bb3fe 100644
--- a/docs/security/credential-vending.md
+++ b/docs/security/credential-vending.md
@@ -227,6 +227,15 @@ The server returns short-lived or static credentials that the client can use to
The Gravitino Spark and Flink connectors automatically call the credential vending API and inject the returned credentials into the connector's configuration, so no connector-side credential configuration is needed. For example, `GravitinoHiveCatalog`, `GravitinoGlueCatalog`, `GravitinoJdbcCatalog`, and `GravitinoIcebergCatalog` all consume the vended credentials transparently.
+### Fileset (GVFS) Client Integration
+
+For the Gravitino Virtual File System (GVFS), credential vending and client-configured storage credentials are **mutually exclusive**, controlled by `fs.gravitino.enableCredentialVending` (Java) / `enable_credential_vending` (Python):
+
+- When **enabled** (`true`), GVFS fetches credentials from the server and uses them to access storage. Any storage credentials configured on the client (for example `s3-access-key-id` / `s3-secret-access-key`) are **ignored**.
+- When **disabled** (`false`, the default), GVFS does not fetch vended credentials; you **must** configure your own storage credentials on the client, otherwise storage access will fail.
+
+In other words, configure credential vending **or** client-side credentials, not both: enabling vending always takes precedence.
+
### Backward Compatibility: `gravitino.catalog.credential.backfillToProperties`
During a rolling upgrade from Gravitino < 1.4.0 to 1.4.0, older clients that read catalog properties directly (rather than calling `/credentials`) would lose access to credentials because the properties are now hidden. To allow a zero-downtime migration, set the following property in `gravitino.conf`: