Added resetpass, nocommands, resetkeys and resetchannels directives in ACL DSL

This commit is contained in:
Kelvin Clement Mwinuka
2023-12-19 10:02:17 +08:00
parent ab86694bc2
commit 1d36d2c772
3 changed files with 30 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ type User struct {
Username string `json:"Username" yaml:"Username"`
Enabled bool `json:"Enabled" yaml:"Enabled"`
NoPassword bool `json:"NoPassword" yaml:"NoPassword"`
NoKeys bool `json:"NoKeys" yaml:"NoKeys"`
Passwords []Password `json:"Passwords" yaml:"Passwords"`
@@ -33,21 +34,24 @@ func (user *User) Normalise() {
}
user.IncludedCommands = RemoveDuplicateEntries(user.IncludedCommands, "allCommands")
if len(user.IncludedCommands) == 0 {
user.IncludedCommands = []string{"*"}
}
user.ExcludedCommands = RemoveDuplicateEntries(user.ExcludedCommands, "allCommands")
if utils.Contains(user.ExcludedCommands, "*") {
user.IncludedCommands = []string{}
}
user.IncludedKeys = RemoveDuplicateEntries(user.IncludedKeys, "allKeys")
if len(user.IncludedKeys) == 0 {
if len(user.IncludedKeys) == 0 && !user.NoKeys {
user.IncludedKeys = []string{"*"}
}
user.IncludedReadKeys = RemoveDuplicateEntries(user.IncludedReadKeys, "allKeys")
if len(user.IncludedReadKeys) == 0 {
if len(user.IncludedReadKeys) == 0 && !user.NoKeys {
user.IncludedReadKeys = []string{"*"}
}
user.IncludedWriteKeys = RemoveDuplicateEntries(user.IncludedWriteKeys, "allKeys")
if len(user.IncludedWriteKeys) == 0 {
if len(user.IncludedWriteKeys) == 0 && !user.NoKeys {
user.IncludedWriteKeys = []string{"*"}
}