Fixed users unlock in ACL LOAD command handler

This commit is contained in:
Kelvin Clement Mwinuka
2024-05-19 04:28:06 +08:00
parent c634b1b20e
commit a9c11adcd6
6 changed files with 930 additions and 830 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -21,7 +21,7 @@ services:
- TLS=false - TLS=false
- MTLS=false - MTLS=false
- BOOTSTRAP_CLUSTER=false - BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml - ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false - REQUIRE_PASS=false
- PASSWORD=password1 - PASSWORD=password1
- FORWARD_COMMAND=false - FORWARD_COMMAND=false
@@ -69,7 +69,7 @@ services:
- TLS=false - TLS=false
- MTLS=false - MTLS=false
- BOOTSTRAP_CLUSTER=true - BOOTSTRAP_CLUSTER=true
# - ACL_CONFIG=/etc/echovault/config/acl.yml - ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false - REQUIRE_PASS=false
- FORWARD_COMMAND=true - FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000 - SNAPSHOT_THRESHOLD=1000
@@ -116,7 +116,7 @@ services:
- TLS=false - TLS=false
- MTLS=false - MTLS=false
- BOOTSTRAP_CLUSTER=false - BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml - ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false - REQUIRE_PASS=false
- FORWARD_COMMAND=true - FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000 - SNAPSHOT_THRESHOLD=1000
@@ -163,7 +163,7 @@ services:
- TLS=false - TLS=false
- MTLS=false - MTLS=false
- BOOTSTRAP_CLUSTER=false - BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml - ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false - REQUIRE_PASS=false
- FORWARD_COMMAND=true - FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000 - SNAPSHOT_THRESHOLD=1000
@@ -210,7 +210,7 @@ services:
- TLS=false - TLS=false
- MTLS=false - MTLS=false
- BOOTSTRAP_CLUSTER=false - BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml - ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false - REQUIRE_PASS=false
- FORWARD_COMMAND=true - FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000 - SNAPSHOT_THRESHOLD=1000
@@ -257,7 +257,7 @@ services:
- TLS=false - TLS=false
- MTLS=false - MTLS=false
- BOOTSTRAP_CLUSTER=false - BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml - ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false - REQUIRE_PASS=false
- FORWARD_COMMAND=true - FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000 - SNAPSHOT_THRESHOLD=1000

View File

@@ -373,7 +373,7 @@ func handleLoad(params internal.HandlerFuncParams) ([]byte, error) {
} }
acl.LockUsers() acl.LockUsers()
defer acl.RUnlockUsers() defer acl.UnlockUsers()
f, err := os.Open(acl.Config.AclConfig) f, err := os.Open(acl.Config.AclConfig)
if err != nil { if err != nil {

View File

@@ -190,6 +190,7 @@ func (user *User) UpdateUser(cmd []string) error {
// Parse channels // Parse channels
if strings.EqualFold(str, "allChannels") { if strings.EqualFold(str, "allChannels") {
user.IncludedPubSubChannels = []string{"*"} user.IncludedPubSubChannels = []string{"*"}
continue
} }
if len(str) > 2 && str[1] == '&' { if len(str) > 2 && str[1] == '&' {
if str[0] == '+' { if str[0] == '+' {

68
volumes/config/acl.json Normal file
View File

@@ -0,0 +1,68 @@
[
{
"Username": "user1",
"Enabled": true,
"NoPassword": false,
"NoKeys": false,
"Passwords": [
{
"PasswordType": "plaintext",
"PasswordValue": "password1"
},
{
"PasswordType": "SHA256",
"PasswordValue": "6cf615d5bcaac778352a8f1f3360d23f02f34ec182e259897fd6ce485d7870d4"
}
],
"IncludedCategories": [
"*"
],
"ExcludedCategories": [],
"IncludedReadKeys": [
"*"
],
"IncludedWriteKeys": [
"*"
],
"IncludedPubSubChannels": [
"*"
],
"ExcludedPubSubChannels": []
},
{
"Username": "user2",
"Enabled": true,
"NoPassword": false,
"NoKeys": false,
"Passwords": [
{
"PasswordType": "plaintext",
"PasswordValue": "password4"
},
{
"PasswordType": "SHA256",
"PasswordValue": "8b2c86ea9cf2ea4eb517fd1e06b74f399e7fec0fef92e3b482a6cf2e2b092023"
}
],
"IncludedCategories": [
"hash",
"set",
"sortedset",
"list",
"generic"
],
"ExcludedCategories": [],
"IncludedReadKeys": [
"*"
],
"IncludedWriteKeys": [
"*"
],
"IncludedPubSubChannels": [
"user:channel:*"
],
"ExcludedPubSubChannels": [
"admin:channel:*"
]
}
]

View File

@@ -0,0 +1,31 @@
- Username: "user1"
Enabled: true
NoPassword: false
NoKeys: false
Passwords:
- PasswordType: "plaintext"
PasswordValue: "password1"
- PasswordType: "SHA256"
PasswordValue: "6cf615d5bcaac778352a8f1f3360d23f02f34ec182e259897fd6ce485d7870d4"
IncludedCategories: ["*"]
ExcludedCategories: []
IncludedReadKeys: ["*"]
IncludedWriteKeys: ["*"]
IncludedPubSubChannels: ["*"]
ExcludedPubSubChannels: []
- Username: "user2"
Enabled: true
NoPassword: false
NoKeys: false
Passwords:
- PasswordType: "plaintext"
PasswordValue: "password4"
- PasswordType: "SHA256"
PasswordValue: "8b2c86ea9cf2ea4eb517fd1e06b74f399e7fec0fef92e3b482a6cf2e2b092023"
IncludedCategories: ["hash", "set", "sortedset", "list", "generic"]
ExcludedCategories: []
IncludedReadKeys: ["*"]
IncludedWriteKeys: ["*"]
IncludedPubSubChannels: ["user:channel:*"]
ExcludedPubSubChannels: ["admin:channel:*"]