You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "quantranhong1999 (via GitHub)" <gi...@apache.org> on 2023/09/25 11:34:59 UTC
[GitHub] [james-project] quantranhong1999 opened a new pull request, #1738: JAMES-3942 Audit user trail
quantranhong1999 opened a new pull request, #1738:
URL: https://github.com/apache/james-project/pull/1738
resolve https://github.com/linagora/james-project/issues/4866
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] chibenwa commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1335844423
##########
server/container/util/src/main/java/org/apache/james/util/AuditTrail.java:
##########
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.util;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class AuditTrail {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AuditTrail.class);
+
+ public static Entry entry() {
+ return new Entry();
+ }
+
+ public static class Entry {
+ Optional<String> username = Optional.empty();
+ Optional<String> remoteIP = Optional.empty();
+ Optional<String> userAgent = Optional.empty();
+ Optional<String> protocol = Optional.empty();
+ Optional<String> action = Optional.empty();
+ Map<String, String> parameters = ImmutableMap.of();
+
+ private Entry() {
+
+ }
+
+ public Entry username(String username) {
+ this.username = Optional.ofNullable(username);
+ return this;
+ }
+
+ public Entry remoteIP(String remoteIP) {
+ this.remoteIP = Optional.ofNullable(remoteIP);
+ return this;
+ }
+
+ public Entry userAgent(String userAgent) {
+ this.userAgent = Optional.ofNullable(userAgent);
+ return this;
+ }
+
+ public Entry protocol(String protocol) {
+ this.protocol = Optional.ofNullable(protocol);
+ return this;
+ }
+
+ public Entry action(String action) {
+ this.action = Optional.ofNullable(action);
+ return this;
+ }
+
+ public Entry parameters(Map<String, String> parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+
+ public void log(String message) {
+ MDCStructuredLogger.forLogger(LOGGER)
Review Comment:
Do that only if logging is turned on please.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-3942 Audit user trail [james-project]
Posted by "vttranlina (via GitHub)" <gi...@apache.org>.
vttranlina commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1342486781
##########
server/container/util/src/main/java/org/apache/james/util/AuditTrail.java:
##########
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.util;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class AuditTrail {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AuditTrail.class);
+
+ public static Entry entry() {
+ return new Entry();
+ }
+
+ public static class Entry {
+ Optional<String> username = Optional.empty();
+ Optional<String> remoteIP = Optional.empty();
+ Optional<String> userAgent = Optional.empty();
+ Optional<String> protocol = Optional.empty();
+ Optional<String> action = Optional.empty();
+ Map<String, String> parameters = ImmutableMap.of();
+
+ private Entry() {
+
+ }
+
+ public Entry username(String username) {
Review Comment:
yes, ignored it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] chibenwa commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1337092609
##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remote/delivery/DeliveryRunnable.java:
##########
@@ -128,6 +133,15 @@ private Mono<Void> processMail(MailQueue.MailQueueItem queueItem) {
// DO NOT CHANGE THIS to catch Error!
// For example, if there were an OutOfMemory condition caused because
// something else in the server was abusing memory, we would not want to start purging the retrying spool!
+ AuditTrail.entry()
+ .protocol("mailetcontainer")
+ .action("RemoteDelivery")
+ .parameters(ImmutableMap.of("mailId", mail.getName(),
+ "mimeMessageId", mail.getMessage().getMessageID(),
+ "sender", mail.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mail.getRecipients())))
Review Comment:
```suggestion
.parameters(() -> ImmutableMap.of("mailId", mail.getName(),
"mimeMessageId", mail.getMessage().getMessageID(),
"sender", mail.getMaybeSender().asString(),
"recipients", StringUtils.join(mail.getRecipients())))
```
Otherwize you would always join strings?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] chibenwa commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1335846264
##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java:
##########
@@ -62,6 +66,15 @@ public LocalDelivery(UsersRepository usersRepository, @Named("mailboxmanager") M
@Override
public void service(Mail mail) throws MessagingException {
+ AuditTrail.entry()
+ .protocol("mailetcontainer")
+ .action("LocalDelivery")
+ .parameters(ImmutableMap.of("mailId", mail.getName(),
+ "mimeMessageId", mail.getMessage().getMessageID(),
+ "sender", mail.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mail.getRecipients())))
+ .log("Local delivering mail.");
Review Comment:
Do it one per recipient, straight after the per recipient success.
##########
server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepository.java:
##########
@@ -64,6 +67,15 @@ public class CassandraMailRepository implements MailRepository {
@Override
public MailKey store(Mail mail) throws MessagingException {
+ AuditTrail.entry()
+ .protocol("mailrepository")
+ .action("store")
+ .parameters(ImmutableMap.of("mailId", mail.getName(),
+ "mimeMessageId", mail.getMessage().getMessageID(),
+ "sender", mail.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mail.getRecipients())))
+ .log("CassandraMailRepository is storing mail.");
Review Comment:
idem
##########
server/data/data-file/src/main/java/org/apache/james/mailrepository/file/FileMailRepository.java:
##########
@@ -171,6 +174,15 @@ public void init() throws Exception {
@Override
public MailKey store(Mail mc) throws MessagingException {
+ AuditTrail.entry()
+ .protocol("mailrepository")
+ .action("store")
+ .parameters(ImmutableMap.of("mailId", mc.getName(),
+ "mimeMessageId", mc.getMessage().getMessageID(),
+ "sender", mc.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mc.getRecipients())))
+ .log("FileMailRepository is storing mail.");
Review Comment:
Please log once the action is done, not before!
##########
server/mailrepository/mailrepository-blob/src/main/scala/org/apache/james/mailrepository/blob/BlobMailRepository.scala:
##########
@@ -147,6 +145,15 @@ class BlobMailRepository(val blobStore: BlobStoreDAO,
@throws[MessagingException]
override def store(mc: Mail): MailKey = {
+ AuditTrail.entry
+ .protocol("mailrepository")
+ .action("store")
+ .parameters(ImmutableMap.of("mailId", mc.getName,
+ "mimeMessageId", mc.getMessage.getMessageID,
+ "sender", mc.getMaybeSender.asString,
+ "recipients", StringUtils.join(mc.getRecipients)))
+ .log("BlobMailRepository is storing mail.")
Review Comment:
Do this once the action succeeded.
##########
server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SendMailHandler.java:
##########
@@ -89,6 +92,18 @@ public HookResult onMessage(SMTPSession session, Mail mail) {
session.getRemoteAddress().getAddress(),
mail.getRecipients(),
holdFor.value());
+
+ AuditTrail.entry()
+ .username(session.getUsername().asString())
+ .remoteIP(session.getRemoteAddress().getAddress().getHostAddress())
Review Comment:
sessionId?
##########
server/mailrepository/mailrepository-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepository.java:
##########
@@ -38,7 +42,16 @@ public MemoryMailRepository() {
}
@Override
- public MailKey store(Mail mail) {
+ public MailKey store(Mail mail) throws MessagingException {
+ AuditTrail.entry()
+ .protocol("mailrepository")
+ .action("store")
+ .parameters(ImmutableMap.of("mailId", mail.getName(),
+ "mimeMessageId", mail.getMessage().getMessageID(),
+ "sender", mail.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mail.getRecipients())))
+ .log("MemoryMailRepository is storing mail.");
Review Comment:
idem
##########
protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java:
##########
@@ -387,6 +389,14 @@ protected Response doAuthTest(SMTPSession session, Username username, String pas
} else if (SMTPRetCode.AUTH_OK.equals(res.getRetCode())) {
// TODO: Make this string a more useful debug message
AUTHENTICATION_DEDICATED_LOGGER.debug("AUTH method {} succeeded", authType);
+
+ AuditTrail.entry()
+ .username(username.asString())
+ .remoteIP(session.getRemoteAddress().getAddress().getHostAddress())
Review Comment:
Let's add a field sessionId
##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java:
##########
@@ -62,6 +66,15 @@ public LocalDelivery(UsersRepository usersRepository, @Named("mailboxmanager") M
@Override
public void service(Mail mail) throws MessagingException {
+ AuditTrail.entry()
+ .protocol("mailetcontainer")
+ .action("LocalDelivery")
+ .parameters(ImmutableMap.of("mailId", mail.getName(),
+ "mimeMessageId", mail.getMessage().getMessageID(),
+ "sender", mail.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mail.getRecipients())))
+ .log("Local delivering mail.");
Review Comment:
Let's add a field: mailboxSessionId
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] Arsnael commented on pull request #1738: JAMES-3942 Audit user trail
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1740256114
https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-1738/5/
Related or not? I find that weird :o
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-3942 Audit user trail [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1746601157
Same again... can you try adding https://github.com/apache/james-project/pull/1748 to see? Getting desperate here :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] vttranlina commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "vttranlina (via GitHub)" <gi...@apache.org>.
vttranlina commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1339500884
##########
server/container/util/src/main/java/org/apache/james/util/AuditTrail.java:
##########
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.util;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class AuditTrail {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AuditTrail.class);
+
+ public static Entry entry() {
+ return new Entry();
+ }
+
+ public static class Entry {
+ Optional<String> username = Optional.empty();
+ Optional<String> remoteIP = Optional.empty();
+ Optional<String> userAgent = Optional.empty();
+ Optional<String> protocol = Optional.empty();
+ Optional<String> action = Optional.empty();
+ Map<String, String> parameters = ImmutableMap.of();
+
+ private Entry() {
+
+ }
+
+ public Entry username(String username) {
Review Comment:
one more method will be less boilerplate?
`public Entry username(Username username)`
`public Entry remoteIP(InetAddress remoteIP)`
...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1336634885
##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java:
##########
@@ -62,6 +66,15 @@ public LocalDelivery(UsersRepository usersRepository, @Named("mailboxmanager") M
@Override
public void service(Mail mail) throws MessagingException {
+ AuditTrail.entry()
+ .protocol("mailetcontainer")
+ .action("LocalDelivery")
+ .parameters(ImmutableMap.of("mailId", mail.getName(),
+ "mimeMessageId", mail.getMessage().getMessageID(),
+ "sender", mail.getMaybeSender().asString(),
+ "recipients", StringUtils.join(mail.getRecipients())))
+ .log("Local delivering mail.");
Review Comment:
> Let's add a field: mailboxSessionId
Can we really get sessionId upon LocalDelivery?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-3942 Audit user trail [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael merged PR #1738:
URL: https://github.com/apache/james-project/pull/1738
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-3942 Audit user trail [james-project]
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1742725891
> It looks quite verbose
Likely could just be eager there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] quantranhong1999 commented on pull request #1738: JAMES-3942 Audit user trail
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1742380463
> Can you squash your fixups @quantranhong1999 ?
I am fixing some remaining review comments. Please wait ^^.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] quantranhong1999 commented on pull request #1738: JAMES-3942 Audit user trail
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1740256846
> Related or not?
Likely related.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1339514529
##########
server/container/util/src/main/java/org/apache/james/util/AuditTrail.java:
##########
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.util;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class AuditTrail {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AuditTrail.class);
+
+ public static Entry entry() {
+ return new Entry();
+ }
+
+ public static class Entry {
+ Optional<String> username = Optional.empty();
+ Optional<String> remoteIP = Optional.empty();
+ Optional<String> userAgent = Optional.empty();
+ Optional<String> protocol = Optional.empty();
+ Optional<String> action = Optional.empty();
+ Map<String, String> parameters = ImmutableMap.of();
+
+ private Entry() {
+
+ }
+
+ public Entry username(String username) {
Review Comment:
> public Entry username(Username username)
I am not sure if I should add `james-core` module into `james-server-util` module. But I will try.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-3942 Audit user trail [james-project]
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1746076292
> But maybe more like a flaky test to me
Yes, it is. I would prefer to investigate that flaky test later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1342280572
##########
server/container/util/src/main/java/org/apache/james/util/AuditTrail.java:
##########
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.util;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class AuditTrail {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AuditTrail.class);
+
+ public static Entry entry() {
+ return new Entry();
+ }
+
+ public static class Entry {
+ Optional<String> username = Optional.empty();
+ Optional<String> remoteIP = Optional.empty();
+ Optional<String> userAgent = Optional.empty();
+ Optional<String> protocol = Optional.empty();
+ Optional<String> action = Optional.empty();
+ Map<String, String> parameters = ImmutableMap.of();
+
+ private Entry() {
+
+ }
+
+ public Entry username(String username) {
Review Comment:
> I am not sure if I should add james-core module into james-server-util module.
circle dependency. Sorry about this...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] chibenwa commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1335843080
##########
protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java:
##########
@@ -387,6 +389,14 @@ protected Response doAuthTest(SMTPSession session, Username username, String pas
} else if (SMTPRetCode.AUTH_OK.equals(res.getRetCode())) {
// TODO: Make this string a more useful debug message
AUTHENTICATION_DEDICATED_LOGGER.debug("AUTH method {} succeeded", authType);
+
+ AuditTrail.entry()
+ .username(username.asString())
+ .remoteIP(session.getRemoteAddress().getAddress().getHostAddress())
+ .protocol("SMTP")
+ .action("AUTH")
+ .parameters(ImmutableMap.of("authType", authType))
+ .log("SMTP Authentication succeeded.");
Review Comment:
Handle the fact that session.getRemoteAddress can be null (if the client disconnects)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] Arsnael commented on pull request #1738: JAMES-3942 Audit user trail
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1742370888
Green build.
Can you squash your fixups @quantranhong1999 ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1738: JAMES-3942 Audit user trail
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on code in PR #1738:
URL: https://github.com/apache/james-project/pull/1738#discussion_r1342280572
##########
server/container/util/src/main/java/org/apache/james/util/AuditTrail.java:
##########
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.util;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class AuditTrail {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AuditTrail.class);
+
+ public static Entry entry() {
+ return new Entry();
+ }
+
+ public static class Entry {
+ Optional<String> username = Optional.empty();
+ Optional<String> remoteIP = Optional.empty();
+ Optional<String> userAgent = Optional.empty();
+ Optional<String> protocol = Optional.empty();
+ Optional<String> action = Optional.empty();
+ Map<String, String> parameters = ImmutableMap.of();
+
+ private Entry() {
+
+ }
+
+ public Entry username(String username) {
Review Comment:
> I am not sure if I should add james-core module into james-server-util module.
Circuit dependency. Sorry on this...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-3942 Audit user trail [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #1738:
URL: https://github.com/apache/james-project/pull/1738#issuecomment-1746022770
The second time in a row I see this error in the builds here: https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-1738/10/testReport/org.apache.james.jmap.memory.upload/InMemoryUploadServiceTest/givenQuotaExceededThenUploadShouldRepairInconsistentCurrentUsage/
I don't believe audit trail is the reason but can you double check please? But maybe more like a flaky test to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org