World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#12670] improve(authz): Show full NameIdentifier in denial messages (#12671)
jarred0214c9f861cad79b
diff --git a/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java b/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.javaindex 11926facc3..8c5e24dac3 100644--- a/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java+++ b/server/src/main/java/org/apache/gravitino/server/web/filter/GravitinoInterceptionService.java@@ -312,7 +312,7 @@ public class GravitinoInterceptionService implements InterceptionService {String contextualMessage;String accessMetadataMessage =accessMetadataName != null- ? String.format("on metadata '%s'", accessMetadataName.name())+ ? String.format("on metadata '%s'", accessMetadataName.toString()): "";if (StringUtils.isNotBlank(errorMessage)) {contextualMessage =diff --git a/server/src/test/java/org/apache/gravitino/server/web/filter/TestGravitinoInterceptionService.java b/server/src/test/java/org/apache/gravitino/server/web/filter/TestGravitinoInterceptionService.javaindex e3548d857c..615e0810d3 100644--- a/server/src/test/java/org/apache/gravitino/server/web/filter/TestGravitinoInterceptionService.java+++ b/server/src/test/java/org/apache/gravitino/server/web/filter/TestGravitinoInterceptionService.java@@ -136,6 +136,38 @@ public class TestGravitinoInterceptionService {}}+ @Test+ public void testNoAuthResponseUsesFullMetadataNameIdentifier() throws Exception {+ MethodInterceptor methodInterceptor =+ new GravitinoInterceptionService()+ .getMethodInterceptors(TestOperations.class.getMethods()[0])+ .get(0);+ Method buildNoAuthResponse =+ methodInterceptor+ .getClass()+ .getDeclaredMethod(+ "buildNoAuthResponse",+ String.class,+ NameIdentifier.class,+ String.class,+ String.class);+ buildNoAuthResponse.setAccessible(true);++ Response response =+ (Response)+ buildNoAuthResponse.invoke(+ methodInterceptor,+ "",+ NameIdentifier.of("testMetalake", "testCatalog", "testSchema", "testTable"),+ "tester",+ "loadTable");++ assertEquals(+ "User 'tester' is not authorized to perform operation 'loadTable' on metadata "+ + "'testMetalake.testCatalog.testSchema.testTable'",+ ((ErrorResponse) response.getEntity()).getMessage());+ }+@Testpublic void testRejectsUnheldActiveRolesWith403() throws Throwable {try (MockedStatic<PrincipalUtils> principalUtilsMocked = mockStatic(PrincipalUtils.class);