Этот коммит содержится в:
Christopher Brown
2017-10-16 23:10:45 -05:00
родитель 89dc3cb126 8bf47c1211
Коммит 39cc237269
31 изменённых файлов: 1415 добавлений и 186 удалений

Просмотреть файл

@@ -518,9 +518,9 @@ func getClientConfig(c *model.Config) map[string]string {
if *License.Features.LDAP {
props["EnableLdap"] = strconv.FormatBool(*c.LdapSettings.Enable)
props["LdapLoginFieldName"] = *c.LdapSettings.LoginFieldName
props["NicknameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.NicknameAttribute != "")
props["FirstNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.FirstNameAttribute != "")
props["LastNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.LastNameAttribute != "")
props["LdapNicknameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.NicknameAttribute != "")
props["LdapFirstNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.FirstNameAttribute != "")
props["LdapLastNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.LastNameAttribute != "")
}
if *License.Features.MFA {
@@ -535,9 +535,9 @@ func getClientConfig(c *model.Config) map[string]string {
if *License.Features.SAML {
props["EnableSaml"] = strconv.FormatBool(*c.SamlSettings.Enable)
props["SamlLoginButtonText"] = *c.SamlSettings.LoginButtonText
props["FirstNameAttributeSet"] = strconv.FormatBool(*c.SamlSettings.FirstNameAttribute != "")
props["LastNameAttributeSet"] = strconv.FormatBool(*c.SamlSettings.LastNameAttribute != "")
props["NicknameAttributeSet"] = strconv.FormatBool(*c.SamlSettings.NicknameAttribute != "")
props["SamlFirstNameAttributeSet"] = strconv.FormatBool(*c.SamlSettings.FirstNameAttribute != "")
props["SamlLastNameAttributeSet"] = strconv.FormatBool(*c.SamlSettings.LastNameAttribute != "")
props["SamlNicknameAttributeSet"] = strconv.FormatBool(*c.SamlSettings.NicknameAttribute != "")
}
if *License.Features.Cluster {

Просмотреть файл

@@ -7,14 +7,13 @@ import (
"crypto/tls"
"mime"
"net"
"net/http"
"net/mail"
"net/smtp"
"time"
"gopkg.in/gomail.v2"
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/html2text"
"github.com/mattermost/mattermost-server/model"
@@ -48,6 +47,20 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) {
return conn, nil
}
// TODO: Remove once this bug is fixed: https://github.com/golang/go/issues/22166
type plainAuthOverTLSConn struct {
smtp.Auth
}
func PlainAuthOverTLSConn(identity, username, password, host string) smtp.Auth {
return &plainAuthOverTLSConn{smtp.PlainAuth(identity, username, password, host)}
}
func (a *plainAuthOverTLSConn) Start(server *smtp.ServerInfo) (string, []byte, error) {
server.TLS = true
return a.Auth.Start(server)
}
func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.AppError) {
c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if err != nil {
@@ -73,7 +86,12 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
}
if *config.EmailSettings.EnableSMTPAuth {
auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
var auth smtp.Auth
if _, ok := conn.(*tls.Conn); ok {
auth = PlainAuthOverTLSConn("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
} else {
auth = smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
}
if err = c.Auth(auth); err != nil {
return nil, model.NewAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error(), http.StatusInternalServerError)