Skip to content
Snippets Groups Projects
Commit f160f1cb authored by ale's avatar ale
Browse files

Requests are in the shared namespace

parent 6fe3e7df
No related branches found
No related tags found
No related merge requests found
......@@ -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:])
default:
log.Printf("unknown key %s", key)
return nil, false, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment