Make the SMTP authentication mechanism configurable - #507
Open
DsgnrFH wants to merge 2 commits into
Open
Conversation
yhabteab
requested changes
Sep 2, 2026
Comment on lines
+38
to
+46
| const ( | ||
| // AuthMechanismAuto picks the SASL mechanism. | ||
| AuthMechanismAuto = "auto" | ||
| // AuthMechanismPlain enforces the SASL PLAIN mechanism. | ||
| AuthMechanismPlain = "plain" | ||
| // AuthMechanismLogin enforces the still widely deployed SASL LOGIN mechanism | ||
| AuthMechanismLogin = "login" | ||
| ) | ||
|
|
Member
There was a problem hiding this comment.
Do you really need these constants? Why not just use the ones from the sasl package instead?
| Password string `json:"password"` // #nosec G117 -- exported password field | ||
| Encryption string `json:"encryption"` | ||
| // AuthMechanism is one of: AuthMechanismAuto, AuthMechanismPlain or AuthMechanismLogin. | ||
| AuthMechanism string `json:"auth_mechanism"` |
Member
There was a problem hiding this comment.
It should be called auth_method instead.
|
|
||
| if password != "" { | ||
| if err = client.Auth(sasl.NewPlainClient("", username, password)); err != nil { | ||
| auth, err := saslClient(client, authMechanism, username, password) |
Member
There was a problem hiding this comment.
This is now guarded by the password check, but shouldn't we already discussed offline that atleast the sasl.OAuthBearer auth method should be supported as well, which doesn't require a password?
| // LOGIN mechanism. This requires an already greeted client, which is the case after the first contact. | ||
| func saslClient(client *smtp.Client, mechanism, username, password string) (sasl.Client, error) { | ||
| switch mechanism { | ||
| case AuthMechanismAuto: |
Member
There was a problem hiding this comment.
Please drop the auto options. The user should know which auth method is supported by the SMTP server he's planning to use. No, need to figure this out on our own.
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.
Resolves #474