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

pinal-shah 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 dba840667 ATLAS-5422:Support no-auth REST notification mode for 
header-based authentication environments (#775)
dba840667 is described below

commit dba84066732830ae5cf58d2a113baef50cea6a2c
Author: bhor-sanket <[email protected]>
AuthorDate: Tue Sep 29 08:33:50 2026 +0530

    ATLAS-5422:Support no-auth REST notification mode for header-based 
authentication environments (#775)
    
    
    Co-authored-by: sanket.bhor <[email protected]>
---
 .../java/org/apache/atlas/AtlasConfiguration.java  |  1 +
 .../atlas/notification/rest/RestNotification.java  |  6 +-
 .../atlas/notification/RestNotificationTest.java   | 89 ++++++++++++++++++++++
 3 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java 
b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
index 882d88f11..897b02ab4 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
@@ -45,6 +45,7 @@ public enum AtlasConfiguration {
 
     NOTIFICATION_HOOK_REST_ENABLED("atlas.hook.rest.notification.enabled", 
false),
     NOTIFICATION_HOOK_REST_ADDRESS("atlas.hook.rest.notification.address", ""),
+    NOTIFICATION_HOOK_REST_AUTH_SKIP("atlas.hook.rest.notification.auth.skip", 
false),
     
NOTIFICATION_HOOK_CONSUMER_TOPIC_NAMES("atlas.notification.hook.consumer.topic.names",
 "ATLAS_HOOK"), //  a comma separated list of topic names
     
NOTIFICATION_ENTITIES_CONSUMER_TOPIC_NAMES("atlas.notification.entities.consumer.topic.names",
 "ATLAS_ENTITIES"), //  a comma separated list of topic names
 
diff --git 
a/notification/src/main/java/org/apache/atlas/notification/rest/RestNotification.java
 
b/notification/src/main/java/org/apache/atlas/notification/rest/RestNotification.java
index 0743545ff..bf1b1c14d 100644
--- 
a/notification/src/main/java/org/apache/atlas/notification/rest/RestNotification.java
+++ 
b/notification/src/main/java/org/apache/atlas/notification/rest/RestNotification.java
@@ -118,7 +118,11 @@ public class RestNotification extends AbstractNotification 
{
                         + AtlasConstants.DEFAULT_REST_NOTIFICATION_ADDRESS + 
")");
             }
 
-            if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
+            if 
(AtlasConfiguration.NOTIFICATION_HOOK_REST_AUTH_SKIP.getBoolean()) {
+                LOG.debug("Client-side authentication skipped; creating client 
without authentication");
+
+                atlasClientV2 = new AtlasClientV2(atlasEndPoint, (String[]) 
null);
+            } else if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
                 String fileAuthUsername = 
configuration.getString(BASIC_AUTH_USERNAME, "admin");
                 String fileAuthPassword = 
configuration.getString(BASIC_AUTH_PASSWORD, "admin123");
 
diff --git 
a/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
 
b/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
index 5db77523b..e3c20f1f1 100644
--- 
a/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
+++ 
b/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
@@ -49,6 +49,7 @@ import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
@@ -196,6 +197,87 @@ public class RestNotificationTest {
         }
     }
 
+    @Test
+    public void testRestNotificationAuthSkipMode() throws Exception {
+        Configuration globalConf = ApplicationProperties.get();
+
+        try {
+            globalConf.setProperty("atlas.hook.rest.notification.auth.skip", 
true);
+
+            Configuration localConf = new BaseConfiguration();
+            localConf.setProperty("atlas.hook.rest.notification.address", 
"http://atlas-rest-notification.example.com:41000/";);
+
+            RestNotification restNotification = new 
RestNotification(localConf);
+
+            String[] configuredEndpoints = 
getConfiguredBaseUrls(restNotification.atlasClientV2);
+
+            assertEquals(configuredEndpoints.length, 1);
+            assertEquals(configuredEndpoints[0], 
"http://atlas-rest-notification.example.com:41000/";);
+        } finally {
+            globalConf.clearProperty("atlas.hook.rest.notification.auth.skip");
+        }
+    }
+
+    @Test
+    public void testAuthSkipModeSkipsBasicAuth() throws Exception {
+        Configuration globalConf = ApplicationProperties.get();
+
+        try {
+            globalConf.setProperty("atlas.hook.rest.notification.auth.skip", 
true);
+
+            Configuration localConf = new BaseConfiguration();
+            localConf.setProperty("atlas.hook.rest.notification.address", 
"http://atlas.example.com:41000/";);
+
+            RestNotification restNotification = new 
RestNotification(localConf);
+
+            String basicAuthUser = 
getBasicAuthUser(restNotification.atlasClientV2);
+
+            assertNull(basicAuthUser, "Auth-skip mode should not set 
basicAuthUser");
+        } finally {
+            globalConf.clearProperty("atlas.hook.rest.notification.auth.skip");
+        }
+    }
+
+    @Test
+    public void testBasicAuthModeSetCredentials() throws Exception {
+        Configuration globalConf = ApplicationProperties.get();
+
+        try {
+            globalConf.setProperty("atlas.hook.rest.notification.auth.skip", 
false);
+
+            Configuration localConf = new BaseConfiguration();
+            localConf.setProperty("atlas.hook.rest.notification.address", 
"http://atlas.example.com:41000/";);
+            localConf.setProperty("atlas.rest.basic.auth.username", 
"testuser");
+            localConf.setProperty("atlas.rest.basic.auth.password", 
"testpass");
+
+            RestNotification restNotification = new 
RestNotification(localConf);
+
+            String basicAuthUser = 
getBasicAuthUser(restNotification.atlasClientV2);
+
+            assertEquals(basicAuthUser, "testuser", "Basic auth mode should 
set basicAuthUser");
+        } finally {
+            globalConf.clearProperty("atlas.hook.rest.notification.auth.skip");
+        }
+    }
+
+    @Test
+    public void testAuthSkipDefaultsToFalseUsesBasicAuth() throws Exception {
+        Configuration globalConf = ApplicationProperties.get();
+
+        globalConf.clearProperty("atlas.hook.rest.notification.auth.skip");
+
+        Configuration localConf = new BaseConfiguration();
+        localConf.setProperty("atlas.hook.rest.notification.address", 
"http://atlas.example.com:41000/";);
+        localConf.setProperty("atlas.rest.basic.auth.username", "admin");
+        localConf.setProperty("atlas.rest.basic.auth.password", "admin123");
+
+        RestNotification restNotification = new RestNotification(localConf);
+
+        String basicAuthUser = 
getBasicAuthUser(restNotification.atlasClientV2);
+
+        assertEquals(basicAuthUser, "admin", "When auth.skip is not set, 
should default to basic auth");
+    }
+
     private String[] getConfiguredBaseUrls(AtlasClientV2 atlasClientV2) throws 
Exception {
         Field clientContextField = 
AtlasBaseClient.class.getDeclaredField("atlasClientContext");
         clientContextField.setAccessible(true);
@@ -206,4 +288,11 @@ public class RestNotificationTest {
 
         return (String[]) baseUrlsField.get(clientContext);
     }
+
+    private String getBasicAuthUser(AtlasClientV2 atlasClientV2) throws 
Exception {
+        Field basicAuthUserField = 
AtlasBaseClient.class.getDeclaredField("basicAuthUser");
+        basicAuthUserField.setAccessible(true);
+
+        return (String) basicAuthUserField.get(atlasClientV2);
+    }
 }

Reply via email to