MCPcopy Create free account
hub / github.com/foxcpp/maddy / AuthPlain

Method AuthPlain

internal/auth/sasl.go:103–126  ·  view source on GitHub ↗
(username, password string)

Source from the content-addressed store, hash-verified

101}
102
103func (s *SASLAuth) AuthPlain(username, password string) error {
104 if len(s.Plain) == 0 {
105 return ErrUnsupportedMech
106 }
107
108 var lastErr error
109 for _, p := range s.Plain {
110 mappedUsername, err := s.usernameForAuth(context.TODO(), username)
111 if err != nil {
112 return err
113 }
114
115 s.Log.DebugMsg("attempting authentication",
116 "mapped_username", mappedUsername, "original_username", username,
117 "module", p)
118
119 lastErr = p.AuthPlain(mappedUsername, password)
120 if lastErr == nil {
121 return nil
122 }
123 }
124
125 return fmt.Errorf("no auth. provider accepted creds, last err: %w", lastErr)
126}
127
128type ContextData struct {
129 // Authentication username. May be different from identity.

Callers 1

CreateSASLMethod · 0.95

Calls 3

usernameForAuthMethod · 0.95
DebugMsgMethod · 0.80
AuthPlainMethod · 0.65

Tested by

no test coverage detected