Call ACL Authorize for command before processing. Call ACL Authenticate when auth command is triggered.

This commit is contained in:
Kelvin Clement Mwinuka
2023-12-14 18:43:56 +08:00
parent 19c9b40b4c
commit 39bf074e33
3 changed files with 23 additions and 4 deletions

View File

@@ -63,7 +63,13 @@ func (p Plugin) HandleCommand(ctx context.Context, cmd []string, server utils.Se
}
func (p Plugin) handleAuth(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) {
return nil, errors.New("AUTH not implemented")
if len(cmd) < 2 || len(cmd) > 3 {
return nil, errors.New("wrong number of arguments")
}
if err := p.acl.AuthenticateConnection(conn, cmd); err != nil {
return nil, err
}
return []byte("+OK\r\n\n"), nil
}
func (p Plugin) handleGetUser(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) {