Skip to content
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

Enhance SMTP LOGIN auth and add comprehensive tests #312

Merged

Conversation

wneessen
Copy link
Owner

@wneessen wneessen commented Oct 2, 2024

Refactored SMTP LOGIN auth to improve compatibility with various server responses, consolidating error handling and response steps. Added extensive tests to verify successful and failed authentication across different server configurations.

In detail, before we were only roughly following the Microsoft spec they defined for MS Outlook.
Meaning:

  • Sending AUTH LOGIN (server might responds with "Username:")
  • Sending the username (server might responds with "Password:")
  • Sending the password (server authenticates)

This is the common approach for most mail systems/providers and is the specified way by Microsoft in their MS-XLOGIN spec.

Yet, there is also an old IETF draft for SMTP AUTH LOGIN that states for clients:

The contents of both challenges SHOULD be ignored.

Since there is no official standard RFC and we've seen different implementations of this mechanism (sending "Username:", "Username", "username", "User name", etc.) we now follow the IETF-Draft instead and ignore any server challange to allow compatiblity with most mail servers/providers. This way it works with servers that follow the Microsoft way but also any other kind of implementation (like i. e. Mox).

This PR closes #311 and addresses https://github.com/mjl-/mox/issues/223

Refactored SMTP LOGIN auth to improve compatibility with various server responses, consolidating error handling and response steps. Added extensive tests to verify successful and failed authentication across different server configurations.
@wneessen wneessen linked an issue Oct 2, 2024 that may be closed by this pull request
Enhanced the LoginAuth test coverage by adding new scenarios with different sequences and invalid cases. This ensures more robust validation and better handling of edge cases in authentication testing.
The addition of `a.respStep = 0` resets the response step counter at the beginning of the AUTH LOGIN process. This ensures that the state starts correctly and avoids potential issues related to residual values from previous authentications.
Changed variable assignment in the test to fix error handling. This ensures the error is properly caught and reported during the client connection process.
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.15%. Comparing base (9bafa96) to head (761e205).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
+ Coverage   80.12%   80.15%   +0.02%     
==========================================
  Files          27       27              
  Lines        2345     2348       +3     
==========================================
+ Hits         1879     1882       +3     
  Misses        353      353              
  Partials      113      113              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wneessen wneessen merged commit c8e4547 into main Oct 2, 2024
22 of 23 checks passed
@wneessen wneessen deleted the bug/311_smtp-auth-login-should-follow-ietf-draft-more-closely branch October 2, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

smtp: AUTH LOGIN should follow ietf-draft more closely
1 participant