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

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 69da2d2c0d [ENAHNCEMENT] Allow easily disabling authentcation (#2800)
69da2d2c0d is described below

commit 69da2d2c0dd42fe48d709f7277e574994b1ef374
Author: Benoit TELLIER <[email protected]>
AuthorDate: Wed Sep 10 07:18:50 2025 +0200

    [ENAHNCEMENT] Allow easily disabling authentcation (#2800)
    
    As it do not make sense on port 25
---
 .../sample-configuration/smtpserver.xml            |  3 +-
 .../sample-configuration/smtpserver.xml            |  3 +-
 .../sample-configuration/smtpserver.xml            |  3 +-
 .../jpa-app/sample-configuration/smtpserver.xml    |  3 +-
 .../sample-configuration/smtpserver.xml            |  3 +-
 .../memory-app/sample-configuration/smtpserver.xml |  3 +-
 .../sample-configuration/smtpserver.xml            |  3 +-
 .../sample-configuration/smtpserver.xml            |  3 +-
 .../james/smtpserver/NoAuthCmdHandlerLoader.java   | 80 ++++++++++++++++++++++
 .../org/apache/james/smtpserver/NoAuthTest.java    | 55 +++++++++++++++
 .../test/resources/smtpserver-disabled-auth.xml    | 48 +++++++++++++
 11 files changed, 191 insertions(+), 16 deletions(-)

diff --git a/server/apps/cassandra-app/sample-configuration/smtpserver.xml 
b/server/apps/cassandra-app/sample-configuration/smtpserver.xml
index a170c94207..67ec0d47c1 100644
--- a/server/apps/cassandra-app/sample-configuration/smtpserver.xml
+++ b/server/apps/cassandra-app/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git a/server/apps/distributed-app/sample-configuration/smtpserver.xml 
b/server/apps/distributed-app/sample-configuration/smtpserver.xml
index 5e49f5bd08..1117546646 100644
--- a/server/apps/distributed-app/sample-configuration/smtpserver.xml
+++ b/server/apps/distributed-app/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git 
a/server/apps/distributed-pop3-app/sample-configuration/smtpserver.xml 
b/server/apps/distributed-pop3-app/sample-configuration/smtpserver.xml
index 0ac589cb1e..5b5d8aa587 100644
--- a/server/apps/distributed-pop3-app/sample-configuration/smtpserver.xml
+++ b/server/apps/distributed-pop3-app/sample-configuration/smtpserver.xml
@@ -45,9 +45,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git a/server/apps/jpa-app/sample-configuration/smtpserver.xml 
b/server/apps/jpa-app/sample-configuration/smtpserver.xml
index 94ed2e5b6a..cd8b82c104 100644
--- a/server/apps/jpa-app/sample-configuration/smtpserver.xml
+++ b/server/apps/jpa-app/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git a/server/apps/jpa-smtp-app/sample-configuration/smtpserver.xml 
b/server/apps/jpa-smtp-app/sample-configuration/smtpserver.xml
index 94ed2e5b6a..cd8b82c104 100644
--- a/server/apps/jpa-smtp-app/sample-configuration/smtpserver.xml
+++ b/server/apps/jpa-smtp-app/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git a/server/apps/memory-app/sample-configuration/smtpserver.xml 
b/server/apps/memory-app/sample-configuration/smtpserver.xml
index 94ed2e5b6a..cd8b82c104 100644
--- a/server/apps/memory-app/sample-configuration/smtpserver.xml
+++ b/server/apps/memory-app/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git a/server/apps/postgres-app/sample-configuration/smtpserver.xml 
b/server/apps/postgres-app/sample-configuration/smtpserver.xml
index 94ed2e5b6a..cd8b82c104 100644
--- a/server/apps/postgres-app/sample-configuration/smtpserver.xml
+++ b/server/apps/postgres-app/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git 
a/server/apps/scaling-pulsar-smtp/sample-configuration/smtpserver.xml 
b/server/apps/scaling-pulsar-smtp/sample-configuration/smtpserver.xml
index b3adb9755c..6b79890186 100644
--- a/server/apps/scaling-pulsar-smtp/sample-configuration/smtpserver.xml
+++ b/server/apps/scaling-pulsar-smtp/sample-configuration/smtpserver.xml
@@ -55,9 +55,8 @@
         <maxmessagesize>0</maxmessagesize>
         <addressBracketsEnforcement>true</addressBracketsEnforcement>
         <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
-        <handlerchain>
+        <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
             <handler 
class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
         </handlerchain>
     </smtpserver>
     <smtpserver enabled="true">
diff --git 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/NoAuthCmdHandlerLoader.java
 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/NoAuthCmdHandlerLoader.java
new file mode 100644
index 0000000000..236ce1b231
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/NoAuthCmdHandlerLoader.java
@@ -0,0 +1,80 @@
+/****************************************************************
+ * 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.james.smtpserver;
+
+import java.util.List;
+
+import org.apache.james.protocols.api.handler.CommandDispatcher;
+import org.apache.james.protocols.api.handler.CommandHandlerResultLogger;
+import org.apache.james.protocols.lib.handler.HandlersPackage;
+import org.apache.james.protocols.smtp.core.ExpnCmdHandler;
+import org.apache.james.protocols.smtp.core.HeloCmdHandler;
+import org.apache.james.protocols.smtp.core.HelpCmdHandler;
+import org.apache.james.protocols.smtp.core.NoopCmdHandler;
+import org.apache.james.protocols.smtp.core.PostmasterAbuseRcptHook;
+import org.apache.james.protocols.smtp.core.QuitCmdHandler;
+import org.apache.james.protocols.smtp.core.ReceivedDataLineFilter;
+import org.apache.james.protocols.smtp.core.RsetCmdHandler;
+import org.apache.james.protocols.smtp.core.UnknownCmdHandler;
+import org.apache.james.protocols.smtp.core.VrfyCmdHandler;
+import org.apache.james.protocols.smtp.core.esmtp.EhloCmdHandler;
+import org.apache.james.protocols.smtp.core.esmtp.MailSizeEsmtpExtension;
+import org.apache.james.protocols.smtp.core.esmtp.StartTlsCmdHandler;
+import org.apache.james.protocols.smtp.core.log.HookResultLogger;
+
+public class NoAuthCmdHandlerLoader implements HandlersPackage {
+
+    static final List<String> commands = List.of(
+            JamesWelcomeMessageHandler.class.getName(),
+            CommandDispatcher.class.getName(),
+            JamesDataCmdHandler.class.getName(),
+            EhloCmdHandler.class.getName(),
+            ExpnCmdHandler.class.getName(),
+            HeloCmdHandler.class.getName(),
+            HelpCmdHandler.class.getName(),
+            JamesMailCmdHandler.class.getName(),
+            NoopCmdHandler.class.getName(),
+            QuitCmdHandler.class.getName(),
+            JamesRcptCmdHandler.class.getName(),
+            RsetCmdHandler.class.getName(),
+            VrfyCmdHandler.class.getName(),
+            MailSizeEsmtpExtension.class.getName(),
+            UsersRepositoryAuthHook.class.getName(),
+            AuthRequiredToRelayRcptHook.class.getName(),
+            SenderAuthIdentifyVerificationHook.class.getName(),
+            PostmasterAbuseRcptHook.class.getName(),
+            ReceivedDataLineFilter.class.getName(),
+            DataLineJamesMessageHookHandler.class.getName(),
+            StartTlsCmdHandler.class.getName(),
+            AddDefaultAttributesMessageHook.class.getName(),
+            SendMailHandler.class.getName(),
+            UnknownCmdHandler.class.getName(),
+            // Add logging stuff
+            CommandHandlerResultLogger.class.getName(),
+            HookResultLogger.class.getName());
+
+    public NoAuthCmdHandlerLoader() {
+    }
+
+    @Override
+    public List<String> getHandlers() {
+        return commands;
+    }
+}
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/NoAuthTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/NoAuthTest.java
new file mode 100644
index 0000000000..3b866bf833
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/NoAuthTest.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.james.smtpserver;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.net.InetSocketAddress;
+
+import org.apache.commons.net.smtp.SMTPClient;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class NoAuthTest {
+    private final SMTPServerTestSystem smtpServerTestSystem = new 
SMTPServerTestSystem();
+
+    @BeforeEach
+    void setUp() throws Exception {
+        smtpServerTestSystem.setUp("smtpserver-disabled-auth.xml");
+    }
+
+    @AfterEach
+    void tearDown() {
+        smtpServerTestSystem.smtpServer.destroy();
+    }
+
+    @Test
+    void authShouldBeDisabled() throws Exception {
+        SMTPClient smtpProtocol = new SMTPClient();
+        InetSocketAddress bindedAddress = 
smtpServerTestSystem.getBindedAddress();
+        smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
+
+        smtpProtocol.sendCommand("EHLO whatever.tld");
+
+        smtpProtocol.sendCommand("AUTH PLAIN");
+
+        assertThat(smtpProtocol.getReplyString()).contains("500 5.5.1 Command 
AUTH unrecognized.");
+    }
+}
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-disabled-auth.xml
 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-disabled-auth.xml
new file mode 100644
index 0000000000..6aea4bb77a
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-disabled-auth.xml
@@ -0,0 +1,48 @@
+<?xml version="1.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.
+ -->
+
+<!-- Read 
https://james.apache.org/server/config-smtp-lmtp.html#SMTP_Configuration for 
further details -->
+
+<smtpserver enabled="true">
+    <bind>0.0.0.0:0</bind>
+    <connectionBacklog>200</connectionBacklog>
+    <tls socketTLS="false" startTLS="false">
+        <keystore>file://conf/keystore</keystore>
+        <secret>james72laBalle</secret>
+        <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+        <algorithm>SunX509</algorithm>
+    </tls>
+    <connectiontimeout>360</connectiontimeout>
+    <connectionLimit>0</connectionLimit>
+    <connectionLimitPerIP>0</connectionLimitPerIP>
+    <auth>
+        <announce>forUnauthorizedAddresses</announce>
+        <requireSSL>false</requireSSL>
+    </auth>
+    <verifyIdentity>true</verifyIdentity>
+    <maxmessagesize>0</maxmessagesize>
+    <addressBracketsEnforcement>true</addressBracketsEnforcement>
+    <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+    <handlerchain 
coreHandlersPackage="org.apache.james.smtpserver.NoAuthCmdHandlerLoader">
+    </handlerchain>
+    <gracefulShutdown>false</gracefulShutdown>
+    <disabledFeatures>ENHANCEDSTATUSCODES</disabledFeatures>
+</smtpserver>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to