This is an automated email from the ASF dual-hosted git repository.
liuxun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new c67a81ba9e [#8101] Improvement(authz): Remove
AuthorizationMetadataPrivileges (#8104)
c67a81ba9e is described below
commit c67a81ba9efbf831ac6f490dced48b1c0e396507
Author: yangyang zhong <[email protected]>
AuthorDate: Wed Aug 27 18:27:01 2025 +0800
[#8101] Improvement(authz): Remove AuthorizationMetadataPrivileges (#8104)
### What changes were proposed in this pull request?
Remove AuthorizationMetadataPrivileges
### Why are the changes needed?
Fix: #8101
### Does this PR introduce _any_ user-facing change?
(Please list the user-facing changes introduced by your change,
including
None
### How was this patch tested?
Existing IT and UT
---
.../AuthorizationMetadataPrivileges.java | 49 ----------------------
.../authorization/annotations/TestAnnotations.java | 23 ----------
2 files changed, 72 deletions(-)
diff --git
a/server-common/src/main/java/org/apache/gravitino/server/authorization/annotations/AuthorizationMetadataPrivileges.java
b/server-common/src/main/java/org/apache/gravitino/server/authorization/annotations/AuthorizationMetadataPrivileges.java
deleted file mode 100644
index 1e2703ccb7..0000000000
---
a/server-common/src/main/java/org/apache/gravitino/server/authorization/annotations/AuthorizationMetadataPrivileges.java
+++ /dev/null
@@ -1,49 +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.server.authorization.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.apache.gravitino.MetadataObject;
-import org.apache.gravitino.authorization.Privilege;
-
-/**
- * Defines the annotation for authorizing access to an API. Use the
resourceType and privileges
- * fields to define the required privileges and resource type for the API.
- */
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AuthorizationMetadataPrivileges {
- /**
- * The list of privileges required to access the API.
- *
- * @return the list of privileges required to access the API.
- */
- Privilege.Name[] privileges();
-
- /**
- * The resource type of the API.
- *
- * @return the resource type of the API.
- */
- MetadataObject.Type metadataType();
-}
diff --git
a/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java
b/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java
index c089119e42..c3fee237f4 100644
---
a/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java
+++
b/server-common/src/test/java/org/apache/gravitino/server/authorization/annotations/TestAnnotations.java
@@ -23,7 +23,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import org.apache.gravitino.Entity;
import org.apache.gravitino.MetadataObject;
-import org.apache.gravitino.authorization.Privilege;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -48,10 +47,6 @@ public class TestAnnotations {
// 1. ResourceAuthorizeApi
// 2. AuthorizationExpression
static class TestAuthorizeAnnotationClass {
- @AuthorizationMetadataPrivileges(
- privileges = {Privilege.Name.CREATE_CATALOG,
Privilege.Name.USE_CATALOG},
- metadataType = MetadataObject.Type.CATALOG)
- public void testAuthedMethodUseResourceType() {}
@AuthorizationExpression(
expression = "CATALOG::CREATE_TABLE || TABLE::CREATE_TABLE",
@@ -59,24 +54,6 @@ public class TestAnnotations {
public void testAuthedMethodUseExpression() {}
}
- @Test
- void testAuthorizeApiWithResourceType() throws NoSuchMethodException {
- Class<TestAuthorizeAnnotationClass> testClass =
TestAuthorizeAnnotationClass.class;
- Method method = testClass.getMethod("testAuthedMethodUseResourceType");
-
- boolean hasAnnotation =
method.isAnnotationPresent(AuthorizationMetadataPrivileges.class);
- Assertions.assertTrue(hasAnnotation);
-
- AuthorizationMetadataPrivileges annotation =
- method.getAnnotation(AuthorizationMetadataPrivileges.class);
- Assertions.assertNotNull(annotation);
-
- Assertions.assertArrayEquals(
- new Privilege.Name[] {Privilege.Name.CREATE_CATALOG,
Privilege.Name.USE_CATALOG},
- annotation.privileges());
- Assertions.assertEquals(MetadataObject.Type.CATALOG,
annotation.metadataType());
- }
-
@Test
void testAuthorizeApiWithExpression() throws NoSuchMethodException {
Class<TestAuthorizeAnnotationClass> testClass =
TestAuthorizeAnnotationClass.class;