- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: support optional SMTP auth#14533
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Signed-off-by: Danny Kopping <danny@coder.com>
| s.log.Warn(ctx,"skipping auth; no username configured",slog.F("support_mechanisms",mechs)) | ||
| }) | ||
| // nolint:nilnil // This is a valid response. | ||
| returnnil,nil |
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.
Is the new return signature handled by the caller(s)? I see that nilnil is new (unless sasl lib also returns it).
Edit: Might be good to mention this return signature in the function comment as well.
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.
Yup.
// Check for authentication capabilities.ifok,avail:=c.Extension("AUTH");ok {<---entersifauthissupported// Ensure the auth mechanisms available are ones we can use.auth,err:=s.auth(ctx,avail)iferr!=nil {returntrue,xerrors.Errorf("determine auth mechanism: %w",err)}// If so, use the auth mechanism to authenticate.ifauth!=nil {<---bailsoutbecauseauthisniliferr:=c.Auth(auth);err!=nil {returntrue,xerrors.Errorf("%T auth: %w",auth,err)}}}elseif!s.cfg.Auth.Empty() {returnfalse,xerrors.New("no authentication mechanisms supported by server")}<---...continuestoprocessmessagewithoutauth...
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.
Admittedly the comments could be better about this case, lemme add that.
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.
Signed-off-by: Danny Kopping <danny@coder.com>
Currently if an SMTP smarthost supports auth mechanisms but does notenforce one to be used, messages will fail to be delivered if blank authentication details are configured.
Currently messages will fail with this misleading error message:
This is a red herring. It stems from always creating an authentication client even if authentication details are not configured - but the smarthost advertises one or more auth mechanisms.
This change bails out of creating the client if authentication details are blank.