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

asf-gitbox-commits pushed a commit to branch pr-675
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 49d761ada2ab04057d4da015043b4fcce44ee3cf
Author: Radhika Kundam <[email protected]>
AuthorDate: Mon Jul 27 10:50:42 2026 -0700

    ATLAS-5326: Enforce Atlas authorization on AdminResource REST endpoints - 
changes as per comments
---
 .../apache/atlas/web/resources/AdminResource.java  | 12 +---
 .../atlas/web/resources/AdminResourceTest.java     | 78 +++++++---------------
 2 files changed, 27 insertions(+), 63 deletions(-)

diff --git 
a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java 
b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
index cb12d4089..b0e3b04b8 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
@@ -362,11 +362,9 @@ public class AdminResource {
     @GET
     @Path("session")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public Response getUserProfile(@Context HttpServletRequest request) throws 
AtlasBaseException {
+    public Response getUserProfile(@Context HttpServletRequest request) {
         LOG.debug("==> AdminResource.getUserProfile()");
 
-        AtlasAuthorizationUtils.verifyAccess(new 
AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_READ), "session");
-
         Response response;
 
         boolean        isEntityUpdateAccessAllowed = false;
@@ -1066,18 +1064,14 @@ public class AdminResource {
     @GET
     @Path("activeSearches")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public Set<String> getActiveSearches() throws AtlasBaseException {
-        AtlasAuthorizationUtils.verifyAccess(new 
AtlasAdminAccessRequest(AtlasPrivilege.ADMIN_EXPORT), "active searches");
-
+    public Set<String> getActiveSearches() {
         return activeSearches.getActiveSearches();
     }
 
     @DELETE
     @Path("activeSearches/{id}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public boolean terminateActiveSearch(@PathParam("id") String searchId) 
throws AtlasBaseException {
-        AtlasAuthorizationUtils.verifyAccess(new 
AtlasAdminAccessRequest(AtlasPrivilege.ADMIN_EXPORT), "terminate active 
search");
-
+    public boolean terminateActiveSearch(@PathParam("id") String searchId) {
         SearchContext terminate = activeSearches.terminate(searchId);
 
         return null != terminate;
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/AdminResourceTest.java 
b/webapp/src/test/java/org/apache/atlas/web/resources/AdminResourceTest.java
index f48874a5a..0402c333f 100644
--- a/webapp/src/test/java/org/apache/atlas/web/resources/AdminResourceTest.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/AdminResourceTest.java
@@ -308,20 +308,14 @@ public class AdminResourceTest {
         // Inject the mocked request
         injectHttpServletRequest(adminResource);
 
-        withAuthorizationBypass(() -> {
-            try {
-                Response response = 
adminResource.getUserProfile(httpServletRequest);
+        Response response = adminResource.getUserProfile(httpServletRequest);
 
-                assertNotNull(response);
-                assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
+        assertNotNull(response);
+        assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
 
-                String responseEntity = (String) response.getEntity();
-                assertNotNull(responseEntity);
-                assertTrue(responseEntity.contains("CSRF_TOKEN") || 
responseEntity.contains("atlas.rest-csrf.enabled"));
-            } catch (AtlasBaseException e) {
-                throw new RuntimeException(e);
-            }
-        });
+        String responseEntity = (String) response.getEntity();
+        assertNotNull(responseEntity);
+        assertTrue(responseEntity.contains("CSRF_TOKEN") || 
responseEntity.contains("atlas.rest-csrf.enabled"));
     }
 
     @Test
@@ -420,19 +414,13 @@ public class AdminResourceTest {
 
         AdminResource adminResource = createAdminResource();
 
-        withAuthorizationBypass(() -> {
-            try {
-                Set<String> result = adminResource.getActiveSearches();
+        Set<String> result = adminResource.getActiveSearches();
 
-                assertNotNull(result);
-                assertEquals(result.size(), 2);
-                assertTrue(result.contains("search1"));
-                assertTrue(result.contains("search2"));
-                verify(activeSearches).getActiveSearches();
-            } catch (AtlasBaseException e) {
-                throw new RuntimeException(e);
-            }
-        });
+        assertNotNull(result);
+        assertEquals(result.size(), 2);
+        assertTrue(result.contains("search1"));
+        assertTrue(result.contains("search2"));
+        verify(activeSearches).getActiveSearches();
     }
 
     @Test
@@ -444,16 +432,10 @@ public class AdminResourceTest {
 
         AdminResource adminResource = createAdminResource();
 
-        withAuthorizationBypass(() -> {
-            try {
-                boolean result = adminResource.terminateActiveSearch(searchId);
+        boolean result = adminResource.terminateActiveSearch(searchId);
 
-                assertTrue(result);
-                verify(activeSearches).terminate(searchId);
-            } catch (AtlasBaseException e) {
-                throw new RuntimeException(e);
-            }
-        });
+        assertTrue(result);
+        verify(activeSearches).terminate(searchId);
     }
 
     @Test
@@ -464,16 +446,10 @@ public class AdminResourceTest {
 
         AdminResource adminResource = createAdminResource();
 
-        withAuthorizationBypass(() -> {
-            try {
-                boolean result = adminResource.terminateActiveSearch(searchId);
+        boolean result = adminResource.terminateActiveSearch(searchId);
 
-                assertFalse(result);
-                verify(activeSearches).terminate(searchId);
-            } catch (AtlasBaseException e) {
-                throw new RuntimeException(e);
-            }
-        });
+        assertFalse(result);
+        verify(activeSearches).terminate(searchId);
     }
 
     @Test
@@ -804,20 +780,14 @@ public class AdminResourceTest {
         try (MockedStatic<SecurityContextHolder> mockedStatic = 
mockStatic(SecurityContextHolder.class)) {
             
mockedStatic.when(SecurityContextHolder::getContext).thenReturn(securityContext);
 
-            withAuthorizationBypass(() -> {
-                try {
-                    Response response = 
adminResource.getUserProfile(httpServletRequest);
+            Response response = 
adminResource.getUserProfile(httpServletRequest);
 
-                    assertNotNull(response);
-                    assertEquals(response.getStatus(), 
HttpServletResponse.SC_OK);
+            assertNotNull(response);
+            assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
 
-                    String responseEntity = (String) response.getEntity();
-                    assertNotNull(responseEntity);
-                    assertTrue(responseEntity.contains("userName") || 
responseEntity.contains("groups"));
-                } catch (AtlasBaseException e) {
-                    throw new RuntimeException(e);
-                }
-            });
+            String responseEntity = (String) response.getEntity();
+            assertNotNull(responseEntity);
+            assertTrue(responseEntity.contains("userName") || 
responseEntity.contains("groups"));
         }
     }
 

Reply via email to