This is an automated email from the ASF dual-hosted git repository.
chaitalicod pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new ffb7a362b ATLAS-5365: Missing SERVICE_NOTIFICATION_POST authorization
on rest-notification NotificationREST POST /topic/{topicName}. (#716)
ffb7a362b is described below
commit ffb7a362b16f12301414aae4eaf58ecb308a7d07
Author: UmeshPatil-1 <[email protected]>
AuthorDate: Fri Aug 7 12:07:43 2026 +0530
ATLAS-5365: Missing SERVICE_NOTIFICATION_POST authorization on
rest-notification NotificationREST POST /topic/{topicName}. (#716)
* ATLAS-5365: Add rest notification authorization and shared error
mappers,and move Jersey exception mappers to server-common with rest web.xml
updates for Java 17 and JSON error parity with webapp.
* ATLAS-5365: Drop explicit Jersey class lists from rest web.xml; rely on
Spring scan (like webapp).
---
.../atlas/notification/rest/web/rest/NotificationREST.java | 5 +++++
rest-notification-webapp/src/main/webapp/WEB-INF/web.xml | 4 ----
server-common/pom.xml | 4 ++++
.../atlas/server/common}/errors/AllExceptionMapper.java | 2 +-
.../server/common}/errors/AtlasBaseExceptionMapper.java | 2 +-
.../atlas/server/common}/errors/ExceptionMapperUtil.java | 8 ++++----
.../server/common}/errors/NotFoundExceptionMapper.java | 2 +-
.../apache/atlas/web/errors/AllExceptionMapperTest.java | 1 +
.../atlas/web/errors/AtlasBaseExceptionMapperTest.java | 14 ++++++++++++++
.../apache/atlas/web/errors/ExceptionMapperUtilTest.java | 1 +
.../atlas/web/errors/NotFoundExceptionMapperTest.java | 1 +
11 files changed, 33 insertions(+), 11 deletions(-)
diff --git
a/rest-notification-webapp/src/main/java/org/apache/atlas/notification/rest/web/rest/NotificationREST.java
b/rest-notification-webapp/src/main/java/org/apache/atlas/notification/rest/web/rest/NotificationREST.java
index 1e9714569..14b9062ca 100644
---
a/rest-notification-webapp/src/main/java/org/apache/atlas/notification/rest/web/rest/NotificationREST.java
+++
b/rest-notification-webapp/src/main/java/org/apache/atlas/notification/rest/web/rest/NotificationREST.java
@@ -21,6 +21,9 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.AtlasErrorCode;
+import org.apache.atlas.authorize.AtlasAdminAccessRequest;
+import org.apache.atlas.authorize.AtlasAuthorizationUtils;
+import org.apache.atlas.authorize.AtlasPrivilege;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.kafka.KafkaNotification;
@@ -88,6 +91,8 @@ public class NotificationREST {
public void handleNotifications(@PathParam("topicName") String topicName,
@Context HttpServletRequest request) throws AtlasBaseException, IOException {
LOG.debug("Handling notifications for topic {}", topicName);
+ AtlasAuthorizationUtils.verifyAccess(new
AtlasAdminAccessRequest(AtlasPrivilege.SERVICE_NOTIFICATION_POST), "post on
rest notification service");
+
if (!TOPICS.contains(topicName)) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_TOPIC_NAME,
topicName);
}
diff --git a/rest-notification-webapp/src/main/webapp/WEB-INF/web.xml
b/rest-notification-webapp/src/main/webapp/WEB-INF/web.xml
index 06647d59e..868fc7029 100644
--- a/rest-notification-webapp/src/main/webapp/WEB-INF/web.xml
+++ b/rest-notification-webapp/src/main/webapp/WEB-INF/web.xml
@@ -31,10 +31,6 @@
<servlet-class>
com.sun.jersey.spi.spring.container.servlet.SpringServlet
</servlet-class>
- <init-param>
- <param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>org.apache.atlas.notification.rest</param-value>
- </init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
diff --git a/server-common/pom.xml b/server-common/pom.xml
index 4298c29c2..7eb80492e 100644
--- a/server-common/pom.xml
+++ b/server-common/pom.xml
@@ -60,6 +60,10 @@
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
diff --git
a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java
b/server-common/src/main/java/org/apache/atlas/server/common/errors/AllExceptionMapper.java
similarity index 97%
rename from
webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java
rename to
server-common/src/main/java/org/apache/atlas/server/common/errors/AllExceptionMapper.java
index aeae95be9..58ed24de1 100644
--- a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java
+++
b/server-common/src/main/java/org/apache/atlas/server/common/errors/AllExceptionMapper.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.atlas.web.errors;
+package org.apache.atlas.server.common.errors;
import org.springframework.stereotype.Component;
diff --git
a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
b/server-common/src/main/java/org/apache/atlas/server/common/errors/AtlasBaseExceptionMapper.java
old mode 100755
new mode 100644
similarity index 98%
rename from
webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
rename to
server-common/src/main/java/org/apache/atlas/server/common/errors/AtlasBaseExceptionMapper.java
index 6f74c83d2..29542b9d3
---
a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java
+++
b/server-common/src/main/java/org/apache/atlas/server/common/errors/AtlasBaseExceptionMapper.java
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.atlas.web.errors;
+package org.apache.atlas.server.common.errors;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
diff --git
a/webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
b/server-common/src/main/java/org/apache/atlas/server/common/errors/ExceptionMapperUtil.java
similarity index 84%
rename from
webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
rename to
server-common/src/main/java/org/apache/atlas/server/common/errors/ExceptionMapperUtil.java
index 5189ea5bf..615aafdb2 100644
--- a/webapp/src/main/java/org/apache/atlas/web/errors/ExceptionMapperUtil.java
+++
b/server-common/src/main/java/org/apache/atlas/server/common/errors/ExceptionMapperUtil.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.atlas.web.errors;
+package org.apache.atlas.server.common.errors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,16 +28,16 @@ public class ExceptionMapperUtil {
}
@SuppressWarnings("UnusedParameters")
- protected static String formatErrorMessage(long id, Exception exception) {
+ public static String formatErrorMessage(long id, Exception exception) {
return String.format("There was an error processing your request. It
has been logged (ID %016x).", id);
}
- protected static void logException(long id, Exception exception) {
+ public static void logException(long id, Exception exception) {
LOGGER.error(formatLogMessage(id, exception), exception);
}
@SuppressWarnings("UnusedParameters")
- protected static String formatLogMessage(long id, Throwable exception) {
+ public static String formatLogMessage(long id, Throwable exception) {
return String.format("Error handling a request: %016x", id);
}
}
diff --git
a/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java
b/server-common/src/main/java/org/apache/atlas/server/common/errors/NotFoundExceptionMapper.java
similarity index 96%
rename from
webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java
rename to
server-common/src/main/java/org/apache/atlas/server/common/errors/NotFoundExceptionMapper.java
index 7aee1ae29..641f3d90f 100644
---
a/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java
+++
b/server-common/src/main/java/org/apache/atlas/server/common/errors/NotFoundExceptionMapper.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.atlas.web.errors;
+package org.apache.atlas.server.common.errors;
import org.apache.atlas.exception.NotFoundException;
import org.springframework.stereotype.Component;
diff --git
a/webapp/src/test/java/org/apache/atlas/web/errors/AllExceptionMapperTest.java
b/webapp/src/test/java/org/apache/atlas/web/errors/AllExceptionMapperTest.java
index 004cfee85..e8934328a 100644
---
a/webapp/src/test/java/org/apache/atlas/web/errors/AllExceptionMapperTest.java
+++
b/webapp/src/test/java/org/apache/atlas/web/errors/AllExceptionMapperTest.java
@@ -18,6 +18,7 @@
package org.apache.atlas.web.errors;
+import org.apache.atlas.server.common.errors.AllExceptionMapper;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
diff --git
a/webapp/src/test/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapperTest.java
b/webapp/src/test/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapperTest.java
index e4543854d..e9672e33e 100644
---
a/webapp/src/test/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapperTest.java
+++
b/webapp/src/test/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapperTest.java
@@ -20,6 +20,7 @@ package org.apache.atlas.web.errors;
import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.server.common.errors.AtlasBaseExceptionMapper;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -82,4 +83,17 @@ public class AtlasBaseExceptionMapperTest {
assertTrue(true);
}
}
+
+ @Test
+ public void testUnauthorizedAccessResponse() {
+ AtlasBaseException testException = new AtlasBaseException(
+ AtlasErrorCode.UNAUTHORIZED_ACCESS, "testuser", "post on rest
notification service");
+
+ Response response = atlasBaseExceptionMapper.toResponse(testException);
+
+ assertEquals(response.getStatus(),
Response.Status.FORBIDDEN.getStatusCode());
+ String entity = (String) response.getEntity();
+ assertTrue(entity.contains("ATLAS-403-00-001"));
+ assertTrue(entity.contains("not authorized to perform post on rest
notification service"));
+ }
}
diff --git
a/webapp/src/test/java/org/apache/atlas/web/errors/ExceptionMapperUtilTest.java
b/webapp/src/test/java/org/apache/atlas/web/errors/ExceptionMapperUtilTest.java
index 83ed8cfaf..12ea8e5c0 100644
---
a/webapp/src/test/java/org/apache/atlas/web/errors/ExceptionMapperUtilTest.java
+++
b/webapp/src/test/java/org/apache/atlas/web/errors/ExceptionMapperUtilTest.java
@@ -18,6 +18,7 @@
package org.apache.atlas.web.errors;
+import org.apache.atlas.server.common.errors.ExceptionMapperUtil;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
diff --git
a/webapp/src/test/java/org/apache/atlas/web/errors/NotFoundExceptionMapperTest.java
b/webapp/src/test/java/org/apache/atlas/web/errors/NotFoundExceptionMapperTest.java
index 988bfd5af..9f643e103 100644
---
a/webapp/src/test/java/org/apache/atlas/web/errors/NotFoundExceptionMapperTest.java
+++
b/webapp/src/test/java/org/apache/atlas/web/errors/NotFoundExceptionMapperTest.java
@@ -19,6 +19,7 @@
package org.apache.atlas.web.errors;
import org.apache.atlas.exception.NotFoundException;
+import org.apache.atlas.server.common.errors.NotFoundExceptionMapper;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;