You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by di...@apache.org on 2026/10/07 22:48:15 UTC

(polaris) branch main updated: Add TABLE_READ_METRICS privilege for metrics RBAC (#5659)

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

dimas-b pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 091d19c3a8 Add TABLE_READ_METRICS privilege for metrics RBAC (#5659)
091d19c3a8 is described below

commit 091d19c3a81f58db8e1942a61098c6ac14da3995
Author: Anand K Sankaran <li...@anands.net>
AuthorDate: Wed Oct 7 15:48:09 2026 -0700

    Add TABLE_READ_METRICS privilege for metrics RBAC (#5659)
    
    * feat(security): add TABLE_READ_METRICS privilege for metrics RBAC
    
    Splits the Management API / grants portion out of PR #4115 (Table
    Metrics Reports query REST API) per dev-list discussion, so it can be
    reviewed and merged independently of the REST endpoint changes.
    
    Adds a new TABLE_READ_METRICS privilege that grants read-only access
    to a table's scan and commit metrics reports without granting access
    to the table's data. It is implied by TABLE_FULL_METADATA and
    restricted to Iceberg tables, since the metrics ingestion and query
    paths only cover Iceberg tables today.
    
    * chore: retrigger CI (Kafka testcontainer flake)
    
    * chore: retrigger CI (helm-unittest plugin download flake)
    
    * fix(security): make TABLE_READ_METRICS actually implied by TABLE_FULL_METADATA
    
    Address PR review feedback: TABLE_FULL_METADATA was claimed to imply
    TABLE_READ_METRICS, but that only becomes true through SUPER_PRIVILEGES
    in PolarisAuthorizerImpl, which was never updated. Also drop the
    ICEBERG_TABLE-only subtype restriction, since securableSubTypes is never
    read for enforcement and grantPrivilegeOnTableToRole accepts both
    subtypes for every privilege; widen it to match the convention used by
    other TABLE_LIKE privileges and clarify the javadoc accordingly.
    
    * docs(security): clarify TABLE_READ_METRICS grant scope vs. report coverage
    
    Address PR review feedback: the docs and CHANGELOG said the privilege
    was "restricted to Iceberg tables," but the enum now allows granting it
    on any table. Clarify that the grant itself isn't restricted by table
    type, only the current metrics report coverage is.
    
    * fix(security): do not imply TABLE_READ_METRICS from TABLE_FULL_METADATA
    
    Per dev-list consensus
    (https://lists.apache.org/thread/6872nwlr8d7j4ns74bjjlwl7yk89v86q):
    metrics reports are closer to an activity log than to table metadata,
    so TABLE_READ_METRICS should require an explicit grant rather than
    being implied by TABLE_FULL_METADATA. Keep it implied by
    CATALOG_MANAGE_CONTENT only, consistent with that privilege already
    implying TABLE_READ_DATA. Update the javadoc, CHANGELOG, and
    access-control.md accordingly.
    
    ---------
    
    Co-authored-by: Anand Kumar Sankaran <an...@workday.com>
---
 CHANGELOG.md                                       |  5 ++++
 .../PolarisManagementServiceIntegrationTest.java   | 34 ++++++++++++++++++++++
 .../polaris/core/auth/PolarisAuthorizerImpl.java   |  3 ++
 .../polaris/core/entity/PolarisPrivilege.java      | 16 ++++++++++
 .../polaris/core/entity/PolarisPrivilegeTest.java  |  3 +-
 .../unreleased/managing-security/access-control.md |  3 +-
 spec/polaris-management-service.yml                |  3 ++
 7 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05ec419257..d33e9f3c27 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -277,6 +277,11 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
 - Semantic models now support dedicated privileges for listing, creating, reading, updating,
   and dropping. Privileges can be granted to catalog roles on individual models or at namespace
   or catalog scope, with separate controls for managing model grants.
+- Added the `TABLE_READ_METRICS` privilege, granting read-only access to a table's scan and
+  commit metrics reports without granting access to the table's data. Not implied by
+  `TABLE_FULL_METADATA`; implied by `CATALOG_MANAGE_CONTENT`, consistent with that privilege
+  already implying `TABLE_READ_DATA`. Can be granted on any table, but metrics reports are
+  currently only produced for Iceberg tables.
 - Python CLI: `catalogs update` now supports `--no-sts` and `--no-kms` to toggle STS/KMS availability on an existing S3 catalog. Previously these were only settable at `catalogs create` time.
 - Python CLI: added `gcp` as an external catalog authentication type for Iceberg REST federation, enabling CLI creation of GCP-authenticated catalogs such as BigLake without passing Google credential secrets through command-line flags.
 - Python CLI: added a global `--page-size` option to paginate list calls internally on Iceberg endpoints. Requires the server-side `LIST_PAGINATION_ENABLED` feature flag.
diff --git a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisManagementServiceIntegrationTest.java b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisManagementServiceIntegrationTest.java
index e5cf286a76..3955536951 100644
--- a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisManagementServiceIntegrationTest.java
+++ b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisManagementServiceIntegrationTest.java
@@ -2053,6 +2053,40 @@ public class PolarisManagementServiceIntegrationTest {
         .hasSize(1);
   }
 
+  @Test
+  public void testGrantListRevokeTableReadMetrics() {
+    String catalogName = client.newEntityName("mycatalog_readmetrics_grant");
+    Catalog catalog =
+        PolarisCatalog.builder()
+            .setType(Catalog.TypeEnum.INTERNAL)
+            .setName(catalogName)
+            .setStorageConfigInfo(new AwsStorageConfigInfo(StorageConfigInfo.StorageTypeEnum.S3))
+            .setProperties(new CatalogProperties("s3://bucket1/"))
+            .build();
+    managementApi.createCatalog(catalog);
+
+    String catalogRoleName = client.newEntityName("mycr_readmetrics_grant");
+    managementApi.createCatalogRole(catalogName, catalogRoleName);
+
+    CatalogGrant grant =
+        new CatalogGrant(CatalogPrivilege.TABLE_READ_METRICS, GrantResource.TypeEnum.CATALOG);
+
+    managementApi.addGrant(catalogName, catalogRoleName, grant);
+    assertThat(managementApi.listGrants(catalogName, catalogRoleName).getGrants())
+        .filteredOn(
+            g ->
+                g instanceof CatalogGrant cg
+                    && cg.getPrivilege() == CatalogPrivilege.TABLE_READ_METRICS)
+        .hasSize(1);
+
+    managementApi.revokeGrant(catalogName, catalogRoleName, grant);
+    assertThat(managementApi.listGrants(catalogName, catalogRoleName).getGrants())
+        .noneMatch(
+            g ->
+                g instanceof CatalogGrant cg
+                    && cg.getPrivilege() == CatalogPrivilege.TABLE_READ_METRICS);
+  }
+
   @Test
   public void testServiceAdminCanTransferCatalogAdmin() {
     // Create a PrincipalRole and a new catalog. Grant the catalog_admin role to the new principal
diff --git a/polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java
index 622b9b8b38..5f4b726188 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java
@@ -105,6 +105,7 @@ import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_LIST_GRANTS;
 import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_MANAGE_GRANTS_ON_SECURABLE;
 import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_MANAGE_STRUCTURE;
 import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_READ_DATA;
+import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_READ_METRICS;
 import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_READ_PROPERTIES;
 import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_REMOVE_PARTITION_SPECS;
 import static org.apache.polaris.core.entity.PolarisPrivilege.TABLE_REMOVE_PROPERTIES;
@@ -464,6 +465,8 @@ public class PolarisAuthorizerImpl implements PolarisAuthorizer {
     SUPER_PRIVILEGES.putAll(
         TABLE_READ_DATA, List.of(CATALOG_MANAGE_CONTENT, TABLE_READ_DATA, TABLE_WRITE_DATA));
     SUPER_PRIVILEGES.putAll(TABLE_WRITE_DATA, List.of(CATALOG_MANAGE_CONTENT, TABLE_WRITE_DATA));
+    SUPER_PRIVILEGES.putAll(
+        TABLE_READ_METRICS, List.of(CATALOG_MANAGE_CONTENT, TABLE_READ_METRICS));
     SUPER_PRIVILEGES.putAll(
         NAMESPACE_FULL_METADATA,
         List.of(CATALOG_MANAGE_CONTENT, CATALOG_MANAGE_METADATA, NAMESPACE_FULL_METADATA));
diff --git a/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisPrivilege.java b/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisPrivilege.java
index b5c72df637..8293b84ad0 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisPrivilege.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisPrivilege.java
@@ -263,6 +263,22 @@ public enum PolarisPrivilege {
   SEMANTIC_MODEL_DROP(107, PolarisEntityType.SEMANTIC_MODEL),
   SEMANTIC_MODEL_FULL_METADATA(108, PolarisEntityType.SEMANTIC_MODEL),
   SEMANTIC_MODEL_MANAGE_GRANTS_ON_SECURABLE(109, PolarisEntityType.SEMANTIC_MODEL),
+  /**
+   * Read-only access to table scan and commit metrics reports. Does not grant access to table data,
+   * and is not implied by {@code TABLE_FULL_METADATA}: metrics reports are closer to an activity
+   * log than to table metadata, so this privilege must be granted explicitly. It is implied by
+   * {@code CATALOG_MANAGE_CONTENT} (see {@code SUPER_PRIVILEGES} in {@link
+   * org.apache.polaris.core.auth.PolarisAuthorizerImpl}), consistent with that privilege already
+   * implying {@code TABLE_READ_DATA}.
+   *
+   * <p>The metrics ingestion and query paths only cover Iceberg tables today; granting this on a
+   * generic table authorizes successfully but returns no reports.
+   */
+  TABLE_READ_METRICS(
+      110,
+      PolarisEntityType.TABLE_LIKE,
+      List.of(PolarisEntitySubType.ICEBERG_TABLE, PolarisEntitySubType.GENERIC_TABLE),
+      PolarisEntityType.CATALOG_ROLE),
   ;
 
   /**
diff --git a/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisPrivilegeTest.java b/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisPrivilegeTest.java
index 51b0724258..f1b6878290 100644
--- a/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisPrivilegeTest.java
+++ b/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisPrivilegeTest.java
@@ -138,7 +138,8 @@ public class PolarisPrivilegeTest {
         Arguments.of(107, PolarisPrivilege.SEMANTIC_MODEL_DROP),
         Arguments.of(108, PolarisPrivilege.SEMANTIC_MODEL_FULL_METADATA),
         Arguments.of(109, PolarisPrivilege.SEMANTIC_MODEL_MANAGE_GRANTS_ON_SECURABLE),
-        Arguments.of(110, null));
+        Arguments.of(110, PolarisPrivilege.TABLE_READ_METRICS),
+        Arguments.of(111, null));
   }
 
   @ParameterizedTest
diff --git a/site/content/in-dev/unreleased/managing-security/access-control.md b/site/content/in-dev/unreleased/managing-security/access-control.md
index 0c9d3e7ba6..248f2ff19e 100644
--- a/site/content/in-dev/unreleased/managing-security/access-control.md
+++ b/site/content/in-dev/unreleased/managing-security/access-control.md
@@ -115,6 +115,7 @@ To grant the full set of privileges (drop, list, read, write, etc.) on an object
 | TABLE_WRITE_PROPERTIES | Enables configuring properties for the table. |
 | TABLE_READ_DATA | Enables reading data from the table by receiving short-lived read-only storage credentials from the catalog. |
 | TABLE_WRITE_DATA | Enables writing data to the table by receiving short-lived read+write storage credentials from the catalog. |
+| TABLE_READ_METRICS | Enables reading table scan and commit metrics reports. Does not grant access to table data. Can be granted on any table, but metrics reports are currently only produced for Iceberg tables. |
 | TABLE_FULL_METADATA | Grants all table privileges, except TABLE_READ_DATA and TABLE_WRITE_DATA, which need to be granted individually. |
 | TABLE_ATTACH_POLICY | Enables attaching policy to a table. |
 | TABLE_DETACH_POLICY | Enables detaching policy from a table. |
@@ -155,7 +156,7 @@ keys, or other secrets in table or view properties.
 | Privilege | Description |
 | -----------------------| ----------- |
 | CATALOG_MANAGE_ACCESS | Includes the ability to grant or revoke privileges on objects in a catalog to catalog roles, and the ability to grant or revoke catalog roles to or from principal roles. |
-| CATALOG_MANAGE_CONTENT | Enables full management of content for the catalog. This privilege encompasses the following privileges:<ul><li>CATALOG_MANAGE_METADATA</li><li>TABLE_FULL_METADATA</li><li>NAMESPACE_FULL_METADATA</li><li>VIEW_FULL_METADATA</li><li>TABLE_WRITE_DATA</li><li>TABLE_READ_DATA</li><li>CATALOG_READ_PROPERTIES</li><li>CATALOG_WRITE_PROPERTIES</li></ul> |
+| CATALOG_MANAGE_CONTENT | Enables full management of content for the catalog. This privilege encompasses the following privileges:<ul><li>CATALOG_MANAGE_METADATA</li><li>TABLE_FULL_METADATA</li><li>NAMESPACE_FULL_METADATA</li><li>VIEW_FULL_METADATA</li><li>TABLE_WRITE_DATA</li><li>TABLE_READ_DATA</li><li>TABLE_READ_METRICS</li><li>CATALOG_READ_PROPERTIES</li><li>CATALOG_WRITE_PROPERTIES</li></ul> |
 | CATALOG_MANAGE_METADATA | Enables full management of the catalog, catalog roles, namespaces, and tables.  |
 | CATALOG_READ_PROPERTIES | Enables listing catalogs and reading properties of the catalog. |
 | CATALOG_WRITE_PROPERTIES | Enables configuring catalog properties. |
diff --git a/spec/polaris-management-service.yml b/spec/polaris-management-service.yml
index 13c5d9ee12..589c827ef4 100644
--- a/spec/polaris-management-service.yml
+++ b/spec/polaris-management-service.yml
@@ -1550,6 +1550,7 @@ components:
         - TABLE_WRITE_PROPERTIES
         - TABLE_READ_DATA
         - TABLE_WRITE_DATA
+        - TABLE_READ_METRICS
         - TABLE_FULL_METADATA
         - TABLE_ATTACH_POLICY
         - TABLE_DETACH_POLICY
@@ -1624,6 +1625,7 @@ components:
         - VIEW_WRITE_PROPERTIES
         - TABLE_READ_DATA
         - TABLE_WRITE_DATA
+        - TABLE_READ_METRICS
         - NAMESPACE_FULL_METADATA
         - TABLE_FULL_METADATA
         - VIEW_FULL_METADATA
@@ -1686,6 +1688,7 @@ components:
         - VIEW_WRITE_PROPERTIES
         - TABLE_READ_DATA
         - TABLE_WRITE_DATA
+        - TABLE_READ_METRICS
         - NAMESPACE_FULL_METADATA
         - TABLE_FULL_METADATA
         - VIEW_FULL_METADATA