From 9069c9cdffd8f2e1a2444821c728b280269a71da Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Tue, 1 Oct 2024 11:03:44 +0200 Subject: [PATCH] Add SCRAM-SHA support to SMTP authentication Introduced additional SMTP authentication mechanisms: SCRAM-SHA-1, SCRAM-SHA-1-PLUS, SCRAM-SHA-256, and SCRAM-SHA-256-PLUS. Added corresponding error messages for unsupported authentication types. This enhances security options for SMTP connections. --- auth.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/auth.go b/auth.go index 4a59b14..d30a154 100644 --- a/auth.go +++ b/auth.go @@ -28,6 +28,11 @@ const ( // SMTPAuthXOAUTH2 is the "XOAUTH2" SASL authentication mechanism. // https://developers.google.com/gmail/imap/xoauth2-protocol SMTPAuthXOAUTH2 SMTPAuthType = "XOAUTH2" + + SMTPAuthSCRAMSHA1 SMTPAuthType = "SCRAM-SHA-1" + SMTPAuthSCRAMSHA1PLUS SMTPAuthType = "SCRAM-SHA-1-PLUS" + SMTPAuthSCRAMSHA256 SMTPAuthType = "SCRAM-SHA-256" + SMTPAuthSCRAMSHA256PLUS SMTPAuthType = "SCRAM-SHA-256-PLUS" ) // SMTP Auth related static errors @@ -43,4 +48,16 @@ var ( // ErrXOauth2AuthNotSupported should be used if the target server does not support the "XOAUTH2" schema ErrXOauth2AuthNotSupported = errors.New("server does not support SMTP AUTH type: XOAUTH2") + + // ErrSCRAMSHA1AuthNotSupported should be used if the target server does not support the "XOAUTH2" schema + ErrSCRAMSHA1AuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-1") + + // ErrSCRAMSHA1PLUSAuthNotSupported should be used if the target server does not support the "XOAUTH2" schema + ErrSCRAMSHA1PLUSAuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-1-PLUS") + + // ErrSCRAMSHA256AuthNotSupported should be used if the target server does not support the "XOAUTH2" schema + ErrSCRAMSHA256AuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-256") + + // ErrSCRAMSHA256PLUSAuthNotSupported should be used if the target server does not support the "XOAUTH2" schema + ErrSCRAMSHA256PLUSAuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-256-PLUS") )