Repository navigation
fix(smtp): AUTH username sets the project again - #358
Merged
Merged
Conversation
go-smtp v0.24 only offers AUTH through the AuthSession interface (AuthMechanisms + Auth); the old AuthPlain method was never called, so every mail landed in the default project and AUTH was refused with 504 Unsupported authentication mechanism. The session now implements AuthSession with PLAIN (go-sasl) and LOGIN (small server-side implementation; go-sasl has only the client). The username, "project" or "project@host", selects the project. Reset no longer clears the project: it runs after every message, while AUTH is per connection, so later mails of the same connection kept the project. Fixes #343
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #343
Problem
In v2 the project key given as the SMTP AUTH username was ignored: every mail landed in the
defaultproject. go-smtp v0.24 offers AUTH only through theAuthSessioninterface (AuthMechanisms+Auth); the oldAuthPlainmethod was never called, and clients got504 Unsupported authentication mechanism.Fix
sessionimplementsgosmtp.AuthSessionwithPLAIN(go-sasl) andLOGIN(a small server side; go-sasl ships only the client). The username —projectorproject@host— selects the project. Any password is accepted, as before.Reset()no longer clears the project. go-smtp calls it after every message, while AUTH is per connection, so the second mail of a connection fell back todefault.github.com/emersion/go-saslmoved from indirect to direct dependency.Tests
go vet ./...;go test ./internal/... ./modules/smtp/ -count=1TestSMTPAuthSetsProjectruns the real SMTP server on a spare port with the real event pipeline and in-memory SQLite, two mails per connection: PLAIN, PLAINuser@host, LOGIN → project; no AUTH →default. Against the old handler it fails with504 Unsupported authentication mechanism.TestSessionSetProject(renamed fromTestSessionAuthPlain).