Commit b7c86593 authored by ale's avatar ale

Handle dovecot dict key lookup prefix properly

parent ba8f75e8
Pipeline #797 passed with stages
in 1 minute and 15 seconds
......@@ -80,17 +80,17 @@ func NewKeyLookupProxy(config *Config) (*KeyLookupProxy, error) {
// Lookup a key using the dovecot dict proxy interface.
//
// We can be sent a userdb lookup, or a passdb lookup, and we can tell
// them apart from the structure of the key:
//
// If it contains passwordSep, then it's a passdb lookup and the key
// consists of 'username' and 'password'. Otherwise, it's a userdb
// lookup and the key is simply the username.
// them apart with the key prefix (passdb/ or userdb/).
func (s *KeyLookupProxy) Lookup(ctx context.Context, key string) (interface{}, bool) {
if strings.Contains(key, passwordSep) {
kparts := strings.SplitN(key, passwordSep, 2)
switch {
case strings.HasPrefix(key, "passdb/"):
kparts := strings.SplitN(key[7:], passwordSep, 2)
return s.lookupPassdb(ctx, kparts[0], kparts[1])
case strings.HasPrefix(key, "userdb/"):
return s.lookupUserdb(ctx, key[7:])
default:
return nil, false
}
return s.lookupUserdb(ctx, key)
}
func (s *KeyLookupProxy) lookupUserdb(ctx context.Context, username string) (interface{}, bool) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment