Skip to content

Commit

Permalink
auth/sasl: Add missing usernameForAuth call
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp committed Jan 28, 2025
1 parent 06fd524 commit c48332a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/auth/sasl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit c48332a

Please sign in to comment.