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

Allow unencrypted PLAIN and LOGIN smtp authentication #344

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

wneessen
Copy link
Owner

This PR implements two new SMTPAuthType types: SMTPAuthPlainNoEnc and SMTPAuthLoginNoEnc options. Both allow PLAIN and LOGIN authentication over unencrypted connections. This can be useful if the connection has already been secured in a different way (e. g. a SSH tunnel).

Refactored the PlainAuth and PlainLogin methods to accept an additional allowUnencryptedAuth parameter. Updated relevant tests to cover the new authentication method.

This PR closes #342

Implemented a new SMTPAuthPlainNoEnc option to allow PLAIN authentication over unencrypted connections. Refactored the PlainAuth function to accept an additional allowUnencryptedAuth parameter. Updated relevant tests to cover the new authentication method.
Implemented an option to allow SMTP LOGIN authentication over unencrypted channels by introducing a new `SMTPAuthLoginNoEnc` type. Updated relevant functions and tests to handle the new parameter for unsecured authentication.
Updated PlainAuth and LoginAuth calls in smtp_test.go and example_test.go to include a 'skipTLS' boolean parameter. This ensures consistent function signatures throughout the test cases and examples.
Introduced new test functions TestAuthPlainNoEnc and TestAuthLoginNoEnc in smtp_test.go to verify behaviors of PlainAuth and LoginAuth without TLS encryption. These tests ensure that authentication mechanisms handle non-encrypted and diverse server configurations correctly.
Update defer statements to log errors if client fails to close in smtp_test.go. Additionally, add a return statement to avoid further errors after a failed SendMail operation.
@wneessen wneessen linked an issue Oct 22, 2024 that may be closed by this pull request
Updated the log level from error to debug for the client.Close() call failure in client_test.go. This change helps reduce noise in test output when the server connection fails.
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 10 lines in your changes missing coverage. Please review.

Project coverage is 84.09%. Comparing base (09133ef) to head (c7d0a03).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
client.go 16.66% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #344      +/-   ##
==========================================
- Coverage   84.46%   84.09%   -0.38%     
==========================================
  Files          27       27              
  Lines        2904     2918      +14     
==========================================
+ Hits         2453     2454       +1     
- Misses        320      332      +12     
- Partials      131      132       +1     

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

@wneessen wneessen merged commit 55e5a15 into main Oct 22, 2024
31 of 32 checks passed
@wneessen wneessen deleted the feature/342_allow-bypass-plain-auth-tls-check branch October 22, 2024 15:39
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.

Allow bypass plain auth tls check
1 participant