auth/sasl: Add missing usernameForAuth call

This commit is contained in:
fox.cpp 2025-01-28 23:34:52 +03:00
parent 06fd5249d2
commit c48332a940
No known key found for this signature in database
GPG key ID: 5B991F6215D2FCC0

View file

@ -139,7 +139,12 @@ func (s *SASLAuth) CreateSASL(mech string, remoteAddr net.Addr, successCb func(i
return ErrInvalidAuthCred
}
err := s.AuthPlain(username, password)
username, err := s.usernameForAuth(context.Background(), username)
if err != nil {
return err
}
err = s.AuthPlain(username, password)
if err != nil {
s.Log.Error("authentication failed", err, "username", username, "src_ip", remoteAddr)
return ErrInvalidAuthCred
@ -156,6 +161,11 @@ func (s *SASLAuth) CreateSASL(mech string, remoteAddr net.Addr, successCb func(i
}
return sasllogin.NewLoginServer(func(username, password string) error {
username, err := s.usernameForAuth(context.Background(), username)
if err != nil {
return err
}
err := s.AuthPlain(username, password)
if err != nil {
s.Log.Error("authentication failed", err, "username", username, "src_ip", remoteAddr)