feat: add Docker deployment and Microsoft OAuth support

This commit is contained in:
2026-04-18 14:02:24 +08:00
parent 6704cfb418
commit e69c0dd226
53 changed files with 5139 additions and 4029 deletions

View File

@@ -0,0 +1,35 @@
package services
import (
"fmt"
"strings"
"github.com/emersion/go-sasl"
)
// xoauth2SASL 实现 Microsoft / Google 邮件使用的 XOAUTH2与 RFC7628 OAUTHBEARER 不同)。
type xoauth2SASL struct {
username string
token string
}
// NewXOAUTH2Client 供 IMAP AUTHENTICATE / SMTP AUTH 使用username 一般为完整邮箱。
func NewXOAUTH2Client(username, accessToken string) sasl.Client {
return &xoauth2SASL{
username: strings.TrimSpace(username),
token: strings.TrimSpace(accessToken),
}
}
func (x *xoauth2SASL) Start() (mech string, ir []byte, err error) {
// https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
s := fmt.Sprintf("user=%s\x01auth=Bearer %s\x01\x01", x.username, x.token)
return "XOAUTH2", []byte(s), nil
}
func (x *xoauth2SASL) Next(challenge []byte) ([]byte, error) {
if len(challenge) == 0 {
return nil, nil
}
return nil, fmt.Errorf("xoauth2: %s", string(challenge))
}