mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
- If the STARTTLS extension is advertised we automatically STARTTLS before authenticating or sending - Uses the secure config key to determine if we should verify the cert. By default it does not verify the cert (should not break any configs) - Attempt auth when the config has a SMTP password and the server supports the AUTH extension and either the PLAIN or LOGIN mechanism - Check the mechanisms supported by the server and use PLAIN or LOGIN depending on which is supported - Changed secure key to use boolean values instead of strings - Arranged SMTP notifier properties/vars to be in the same order - Log the steps for STARTTLS (debug only) - Log the steps for AUTH (debug only)
35 lines
714 B
Go
35 lines
714 B
Go
package notification
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"net/smtp"
|
|
)
|
|
|
|
type loginAuth struct {
|
|
username string
|
|
password string
|
|
}
|
|
|
|
func LoginAuth(username, password string) smtp.Auth {
|
|
return &loginAuth{username, password}
|
|
}
|
|
|
|
func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
|
|
return "LOGIN", []byte{}, nil
|
|
}
|
|
|
|
func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
|
|
if !more {
|
|
return nil, nil
|
|
}
|
|
switch {
|
|
case bytes.Equal(fromServer, []byte("Username:")):
|
|
return []byte(a.username), nil
|
|
case bytes.Equal(fromServer, []byte("Password:")):
|
|
return []byte(a.password), nil
|
|
default:
|
|
return nil, fmt.Errorf("Unexpected challenge/data from server: %s.", fromServer)
|
|
}
|
|
}
|