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

Method usernameForAuth

internal/auth/sasl.go:75–101  ·  view source on GitHub ↗
(ctx context.Context, saslUsername string)

Source from the content-addressed store, hash-verified

73}
74
75func (s *SASLAuth) usernameForAuth(ctx context.Context, saslUsername string) (string, error) {
76 if s.AuthNormalize != nil {
77 var err error
78 saslUsername, err = s.AuthNormalize(saslUsername)
79 if err != nil {
80 return "", err
81 }
82 }
83
84 if s.AuthMap == nil {
85 return saslUsername, nil
86 }
87
88 mapped, ok, err := s.AuthMap.Lookup(ctx, saslUsername)
89 if err != nil {
90 return "", err
91 }
92 if !ok {
93 return "", ErrInvalidAuthCred
94 }
95
96 if saslUsername != mapped {
97 s.Log.DebugMsg("using mapped username for authentication", "username", saslUsername, "mapped_username", mapped)
98 }
99
100 return mapped, nil
101}
102
103func (s *SASLAuth) AuthPlain(username, password string) error {
104 if len(s.Plain) == 0 {

Callers 2

AuthPlainMethod · 0.95
CreateSASLMethod · 0.95

Calls 2

DebugMsgMethod · 0.80
LookupMethod · 0.65

Tested by

no test coverage detected