This is an automated email from the ASF dual-hosted git repository. rcordier 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 d241742a47 [ENHANCEMENT] Logs for sender identity verification d241742a47 is described below commit d241742a472c457fd5dae03cbeb51ee8b0ec6871 Author: Benoit TELLIER <btell...@linagora.com> AuthorDate: Wed Nov 20 17:16:47 2024 +0100 [ENHANCEMENT] Logs for sender identity verification Invaluable for debugging admin / user configuration issues. A MUST HAVE. --- .../smtp/core/AbstractSenderAuthIdentifyVerificationHook.java | 5 +++++ .../apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java index 459552894a..8f78f8b0b7 100644 --- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java +++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/AbstractSenderAuthIdentifyVerificationHook.java @@ -29,6 +29,8 @@ import org.apache.james.protocols.smtp.hook.HookResult; import org.apache.james.protocols.smtp.hook.HookReturnCode; import org.apache.james.protocols.smtp.hook.MailHook; import org.apache.james.protocols.smtp.hook.RcptHook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; @@ -48,6 +50,7 @@ public abstract class AbstractSenderAuthIdentifyVerificationHook implements Mail .smtpDescription(DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH) + " Authentication Required") .build(); + public static final Logger LOGGER = LoggerFactory.getLogger(AbstractSenderAuthIdentifyVerificationHook.class); /* * Check if the sender address is the same as the user which was used to authenticate. @@ -68,8 +71,10 @@ public abstract class AbstractSenderAuthIdentifyVerificationHook implements Mail protected HookResult doCheck(SMTPSession session, MaybeSender sender) { if (senderDoesNotMatchAuthUser(session, sender)) { + LOGGER.warn("{} tried to send an email as {}", session.getUsername(), sender.asString()); return INVALID_AUTH; } else if (unauthenticatedSenderIsLocalUser(session, sender)) { + LOGGER.info("Authentication is required for sending emails as a local user ({})", sender.asString()); return AUTH_REQUIRED; } else { return HookResult.DECLINED; diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java index 095bcd373b..a5a0bc4325 100644 --- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java +++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java @@ -79,11 +79,14 @@ public class SenderAuthIdentifyVerificationHook extends AbstractSenderAuthIdenti private HookResult doCheckRelaxed(SMTPSession session, MaybeSender sender) { if (senderDoesNotMatchAuthUser(session, sender)) { + LOGGER.warn("{} tried to send an email as {}", session.getUsername(), sender.asString()); return INVALID_AUTH; } else if (unauthenticatedSenderIsLocalUser(session, sender)) { if (mxHeuristic(session)) { return HookResult.DECLINED; } else { + LOGGER.info("Authentication is required for sending emails as a local user ({})" + + " - we infered the sender not to be a MX so the check is enforced.", sender.asString()); return AUTH_REQUIRED; } } else { --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org