mchades commented on code in PR #12797:
URL: https://github.com/apache/gravitino/pull/12797#discussion_r3920542819


##########
server/src/main/java/org/apache/gravitino/server/web/rest/ViewOperations.java:
##########
@@ -68,17 +74,27 @@ public ViewOperations(ViewDispatcher dispatcher) {
   @Produces("application/vnd.gravitino.v1+json")
   @Timed(name = "list-view." + MetricNames.HTTP_PROCESS_DURATION, absolute = 
true)
   @ResponseMetered(name = "list-view", absolute = true)
+  @AuthorizationExpression(
+      expression = 
AuthorizationExpressionConstants.LOAD_SCHEMA_AUTHORIZATION_EXPRESSION,
+      accessMetadataType = MetadataObject.Type.SCHEMA)
   public Response listViews(
-      @PathParam("metalake") String metalake,
-      @PathParam("catalog") String catalog,
-      @PathParam("schema") String schema) {
+      @PathParam("metalake") @AuthorizationMetadata(type = 
Entity.EntityType.METALAKE)
+          String metalake,
+      @PathParam("catalog") @AuthorizationMetadata(type = 
Entity.EntityType.CATALOG) String catalog,
+      @PathParam("schema") @AuthorizationMetadata(type = 
Entity.EntityType.SCHEMA) String schema) {
     LOG.info("Received list views request for schema: {}.{}.{}", metalake, 
catalog, schema);
     try {
       return Utils.doAs(
           httpRequest,
           () -> {
             Namespace viewNS = NamespaceUtil.ofView(metalake, catalog, schema);
             NameIdentifier[] idents = dispatcher.listViews(viewNS);
+            idents =
+                MetadataAuthzHelper.filterByExpression(
+                    metalake,
+                    
AuthorizationExpressionConstants.FILTER_VIEW_AUTHORIZATION_EXPRESSION,
+                    Entity.EntityType.VIEW,
+                    idents);

Review Comment:
   This is intentional and matches the existing list endpoints, including 
`TableOperations`, `FilesetOperations`, and `IcebergViewOperations`. 
`MetadataAuthzHelper.filterByExpression` centrally checks 
`Configs.ENABLE_AUTHORIZATION` and returns the original array when 
authorization is disabled. Keeping that check centralized avoids duplicating 
configuration logic in each REST resource.



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