Commit f160f1cb authored by ale's avatar ale
Browse files

Requests are in the shared namespace

parent 6fe3e7df
Pipeline #805 passed with stages
in 47 seconds
......@@ -78,17 +78,22 @@ func NewKeyLookupProxy(config *Config) (*KeyLookupProxy, error) {
}, nil
const (
namespace = "shared"
namespaceLen = len(namespace)
// 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 with the key prefix (passdb/ or userdb/).
func (s *KeyLookupProxy) Lookup(ctx context.Context, key string) (interface{}, bool, error) {
switch {
case strings.HasPrefix(key, "passdb/"):
kparts := strings.SplitN(key[7:], passwordSep, 2)
case strings.HasPrefix(key, namespace+"/passdb/"):
kparts := strings.SplitN(key[namespaceLen+8:], passwordSep, 2)
return s.lookupPassdb(ctx, kparts[0], kparts[1])
case strings.HasPrefix(key, "userdb/"):
return s.lookupUserdb(ctx, key[7:])
case strings.HasPrefix(key, namespace+"/userdb/"):
return s.lookupUserdb(ctx, key[namespaceLen+8:])
log.Printf("unknown key %s", key)
return nil, false, nil
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