mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-01 14:58:03 +02:00
Merge pull request #4375 from ywk253100/180308_smtp_tls
Do the authentication with CRAM-MD5 when the connection is insecure
This commit is contained in:
commit
685140cda8
@ -130,6 +130,7 @@ func newClient(addr, identity, username, password string,
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
tls = true
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("the email server %s does not support STARTTLS", addr)
|
log.Debugf("the email server %s does not support STARTTLS", addr)
|
||||||
}
|
}
|
||||||
@ -137,9 +138,13 @@ func newClient(addr, identity, username, password string,
|
|||||||
|
|
||||||
if ok, _ := client.Extension("AUTH"); ok {
|
if ok, _ := client.Extension("AUTH"); ok {
|
||||||
log.Debug("authenticating the client...")
|
log.Debug("authenticating the client...")
|
||||||
// only support plain auth
|
var auth smtp.Auth
|
||||||
if err = client.Auth(smtp.PlainAuth(identity,
|
if tls {
|
||||||
username, password, host)); err != nil {
|
auth = smtp.PlainAuth(identity, username, password, host)
|
||||||
|
} else {
|
||||||
|
auth = smtp.CRAMMD5Auth(username, password)
|
||||||
|
}
|
||||||
|
if err = client.Auth(auth); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user