Skip to content

Commit

Permalink
Fixed users unlock in ACL LOAD command handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinmwinuka committed May 18, 2024
1 parent c634b1b commit a9c11ad
Show file tree
Hide file tree
Showing 6 changed files with 1,301 additions and 1,201 deletions.
2,388 changes: 1,194 additions & 1,194 deletions coverage/coverage.out

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml
- ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false
- PASSWORD=password1
- FORWARD_COMMAND=false
Expand Down Expand Up @@ -69,7 +69,7 @@ services:
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=true
# - ACL_CONFIG=/etc/echovault/config/acl.yml
- ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false
- FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000
Expand Down Expand Up @@ -116,7 +116,7 @@ services:
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml
- ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false
- FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000
Expand Down Expand Up @@ -163,7 +163,7 @@ services:
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml
- ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false
- FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000
Expand Down Expand Up @@ -210,7 +210,7 @@ services:
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml
- ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false
- FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000
Expand Down Expand Up @@ -257,7 +257,7 @@ services:
- TLS=false
- MTLS=false
- BOOTSTRAP_CLUSTER=false
# - ACL_CONFIG=/etc/echovault/config/acl.yml
- ACL_CONFIG=/etc/echovault/config/acl.yml
- REQUIRE_PASS=false
- FORWARD_COMMAND=true
- SNAPSHOT_THRESHOLD=1000
Expand Down
2 changes: 1 addition & 1 deletion internal/modules/acl/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func handleLoad(params internal.HandlerFuncParams) ([]byte, error) {
}

acl.LockUsers()
defer acl.RUnlockUsers()
defer acl.UnlockUsers()

Check warning on line 376 in internal/modules/acl/commands.go

View check run for this annotation

Codecov / codecov/patch

internal/modules/acl/commands.go#L376

Added line #L376 was not covered by tests

f, err := os.Open(acl.Config.AclConfig)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/modules/acl/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (user *User) UpdateUser(cmd []string) error {
// Parse channels
if strings.EqualFold(str, "allChannels") {
user.IncludedPubSubChannels = []string{"*"}
continue
}
if len(str) > 2 && str[1] == '&' {
if str[0] == '+' {
Expand Down
68 changes: 68 additions & 0 deletions volumes/config/acl.json
Original file line number Diff line number Diff line change
@@ -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:*"
]
}
]
31 changes: 31 additions & 0 deletions volumes/config/acl.yml
Original file line number Diff line number Diff line change
@@ -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:*"]

0 comments on commit a9c11ad

Please sign in to comment.