-
Notifications
You must be signed in to change notification settings - Fork 488
JAMES-4171 Allow configure strong distinction between submission and … #2939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,10 +74,14 @@ public SenderAuthIdentifyVerificationHook(DomainList domains, UsersRepository us | |
| @Override | ||
| public HookResult doCheck(SMTPSession session, MaybeSender sender) { | ||
| ExtendedSMTPSession nSession = (ExtendedSMTPSession) session; | ||
| if (nSession.verifyIdentity() == SMTPConfiguration.SenderVerificationMode.STRICT) { | ||
| if (!session.isRelayingAllowed() && !nSession.senderVerificationConfiguration().allowUnauthenticatedSender()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this comment on the corresponding jira it was discussed adding a new defaultly loaded hook instead of changing the behaviour of an existing hook did you change your mind ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I have some local work adapting this that apparently is not shared in the right place.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CF #2941 |
||
| LOGGER.info("Authentication is required for sending email (sender: {})", sender.asString()); | ||
| return AUTH_REQUIRED; | ||
| } | ||
| if (nSession.senderVerificationConfiguration().mode() == SMTPConfiguration.SenderVerificationMode.STRICT) { | ||
| return super.doCheck(session, sender); | ||
| } else if (nSession.verifyIdentity() == SMTPConfiguration.SenderVerificationMode.RELAXED) { | ||
| return doCheckRelaxed(session, sender); | ||
| } else if (nSession.senderVerificationConfiguration().mode() == SMTPConfiguration.SenderVerificationMode.RELAXED) { | ||
| return doCheckRelaxed(nSession, sender); | ||
| } else { | ||
| return HookResult.DECLINED; | ||
| } | ||
|
|
@@ -140,8 +144,8 @@ protected boolean isSenderAllowed(Username connectedUser, Username sender) { | |
| @Override | ||
| public HookResult onMessage(SMTPSession session, Mail mail) { | ||
| ExtendedSMTPSession nSession = (ExtendedSMTPSession) session; | ||
| boolean shouldCheck = nSession.verifyIdentity() == SMTPConfiguration.SenderVerificationMode.STRICT || | ||
| (nSession.verifyIdentity() == SMTPConfiguration.SenderVerificationMode.RELAXED && session.getUsername() != null); | ||
| boolean shouldCheck = nSession.senderVerificationConfiguration().mode() == SMTPConfiguration.SenderVerificationMode.STRICT || | ||
| (nSession.senderVerificationConfiguration().mode() == SMTPConfiguration.SenderVerificationMode.RELAXED && session.getUsername() != null); | ||
| if (shouldCheck) { | ||
| try { | ||
| Address[] fromAddresses = mail.getMessage().getFrom(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick