mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-09 09:50:09 +08:00
Added KeyExtractionFunc for all commands and sub commands to extract keys for ACL authorization.
Deleted genpass command.
This commit is contained in:
@@ -51,8 +51,6 @@ func (p Plugin) HandleCommand(ctx context.Context, cmd []string, server utils.Se
|
||||
return p.handleDelUser(ctx, cmd, server)
|
||||
case "whoami":
|
||||
return p.handleWhoAmI(ctx, cmd, server)
|
||||
case "genpass":
|
||||
return p.handleGenPass(ctx, cmd, server)
|
||||
case "list":
|
||||
return p.handleList(ctx, cmd, server)
|
||||
case "load":
|
||||
@@ -92,10 +90,6 @@ func (p Plugin) handleWhoAmI(ctx context.Context, cmd []string, server utils.Ser
|
||||
return nil, errors.New("ACL WHOAMI not implemented")
|
||||
}
|
||||
|
||||
func (p Plugin) handleGenPass(ctx context.Context, cmd []string, server utils.Server) ([]byte, error) {
|
||||
return nil, errors.New("ACL GENPASS not implemented")
|
||||
}
|
||||
|
||||
func (p Plugin) handleList(ctx context.Context, cmd []string, server utils.Server) ([]byte, error) {
|
||||
return nil, errors.New("ACL LIST not implemented")
|
||||
}
|
||||
@@ -117,75 +111,98 @@ func NewModule(acl *ACL) Plugin {
|
||||
{
|
||||
Command: "auth",
|
||||
Categories: []string{},
|
||||
Description: "Authenticates the connection",
|
||||
Description: "(AUTH [username] password) Authenticates the connection",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "acl",
|
||||
Categories: []string{},
|
||||
Description: "List all the categories and commands inside a category",
|
||||
Description: "Access-Control-List commands",
|
||||
Sync: false,
|
||||
SubCommands: []utils.SubCommand{
|
||||
{
|
||||
Command: "cat",
|
||||
Categories: []string{},
|
||||
Description: "List all the categories and commands inside a category",
|
||||
Description: "(ACL CAT) List all the categories and commands inside a category.",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "users",
|
||||
Categories: []string{},
|
||||
Description: "List all ACL users",
|
||||
Description: "(ACL LIST) List all ACL users",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "setuser",
|
||||
Categories: []string{},
|
||||
Description: "Configure a new or existing user",
|
||||
Description: "(ACL SETUSER) Configure a new or existing user",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "getuser",
|
||||
Categories: []string{},
|
||||
Description: "List the ACL rules of a user",
|
||||
Description: "(ACL GETUSER) List the ACL rules of a user",
|
||||
Sync: false,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "deluser",
|
||||
Categories: []string{},
|
||||
Description: "Deletes users and terminates their connections",
|
||||
Description: "(ACL DELUSER) Deletes users and terminates their connections",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "whoami",
|
||||
Categories: []string{},
|
||||
Description: "Returns the authenticated user of the current connection",
|
||||
Sync: true,
|
||||
},
|
||||
|
||||
{
|
||||
Command: "genpass",
|
||||
Categories: []string{},
|
||||
Description: "Generates a password that can be used to identify a user",
|
||||
Description: "(ACL WHOAMI) Returns the authenticated user of the current connection",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "list",
|
||||
Categories: []string{},
|
||||
Description: "Dumps effective acl rules in acl config file format",
|
||||
Description: "(ACL LIST) Dumps effective acl rules in acl config file format",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "load",
|
||||
Categories: []string{},
|
||||
Description: "Reloads the rules from the configured ACL config file",
|
||||
Description: "(ACL LOAD) Reloads the rules from the configured ACL config file",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Command: "save",
|
||||
Categories: []string{},
|
||||
Description: "Saves the effective ACL rules the configured ACL config file",
|
||||
Description: "(ACL SAVE) Saves the effective ACL rules the configured ACL config file",
|
||||
Sync: true,
|
||||
KeyExtractionFunc: func(cmd []string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user