Repository navigation
[BLOG POST] Rethinking Valkey ACLs with ACL Roles #806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kjaymiller
wants to merge
9
commits into
valkey-io:main
Choose a base branch
from
kjaymiller:blog-valkey-acl-roles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+125
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9162eb2
create acl roles blog post
kjaymiller 1314093
fix spelling on authors/kjaymiller.md
kjaymiller 0eec2ab
add missing link for 9.2 announcement
kjaymiller cde6edb
Fixes small style issues with versions
stockholmux 887397a
Fix typo in bio
stockholmux 84766a8
Grammatical person fix
stockholmux 57f4a1a
set date of blog post to 12/03
kjaymiller a5fe01d
Update content/blog/2026-12-03-rethinking-valkey-ACLs-with-ACL-roles/…
crystalphamLF cc863ad
move publish date to 12-07
kjaymiller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| title: Jay Miller | ||
| extra: | ||
| photo: "/assets/media/authors/kjaymiller.jpg" | ||
| github: kjaymiller | ||
| --- | ||
|
|
||
| Jay Miller is a Developer Advocate and a founder of Black Python Devs. | ||
|
|
||
| Jay is a recognized leader in the Python community globally and has advocated for other communities such as PostgreSQL and Valkey. | ||
|
|
||
| When not writing or writing about code, Jay can often be seen cheering on their local baseball team, or spending time with their family, pets, and many many houseplants. | ||
113 changes: 113 additions & 0 deletions
113
content/blog/2026-12-07-rethinking-valkey-ACLs-with-ACL-roles/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| +++ | ||
| title = "Rethinking Valkey ACLs with ACL Roles" | ||
| description = "Valkey 9.2 allows you to group and manage permisisons in ACL Roles" | ||
| draft = true | ||
| date = 2026-12-07 | ||
| authors = ["kjaymiller"] | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| +++ | ||
|
|
||
| With the recent release of [Valkey 9.2][Valkey 9.2 Announcement], Access Control Lists (ACLs) gained the ability to be defined in _roles_, to go alongside per user assignments. This greatly improves how ACLs can be applied and managed. | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| ## What are ACLs | ||
|
|
||
| An ACL is a rule that grants or restricts access to specific commands, keys, channels, and databases. Valkey's ACLs use a domain-specific language to allow or deny a user access to each of them. | ||
|
|
||
| ``` | ||
| # create a user that can only read keys (but has access to all keys '~*') | ||
| ACL SETUSER read-only-user on #<SHA256_HASH_OF_PASSWORD> ~* +@read | ||
| ``` | ||
|
|
||
| ## ACLs prior to 9.2 | ||
|
|
||
| ACLs have been in Valkey since its creation. They serve several purposes all around _access_ (hence the name) and auditability. | ||
|
|
||
| When your Valkey cluster is connecting to several applications and users, you end up with a complicated `aclfile` that you have to maintain. | ||
|
|
||
| Each rule in this file controls access along several dimensions: which user, which keys, which commands, and which channels. In Valkey 9.1, per-database rules (using `db=`) added one more. Every rule below is pinned to db=0, so the sample below grows quickly once you add databases. | ||
|
|
||
| ``` | ||
| # Rules apply left to right. Each user starts from -@all and adds, so new command categories fail closed. | ||
|
|
||
| # lock down default | ||
| user default off resetkeys resetchannels resetdbs -@all | ||
|
|
||
| # --- internal / infra --- | ||
| user replica-sync on #<HASH:replica-sync> resetkeys +psync +replconf +ping | ||
| user sentinel-admin on #<HASH:sentinel-admin> resetkeys allchannels +multi +slaveof +ping +exec +subscribe +config|rewrite +role +publish +info +client|setname +client|kill +script|kill | ||
| # config|get dropped: it returns masterauth/requirepass. Re-add only if the exporter needs it. | ||
| user metrics-exporter on #<HASH:metrics-exporter> resetkeys resetchannels db=0 -@all +ping +info +client|list +slowlog|get +latency|latest +memory|stats +dbsize | ||
|
|
||
| # --- apps --- | ||
| user checkout-svc on #<HASH:checkout-svc> resetkeys resetchannels db=0 ~checkout:* ~session:* %R~catalog:* &checkout-events:* -@all +@read +@write +@pubsub -@dangerous -@admin -@scripting +ping +hello +client|setname +client|setinfo | ||
| user catalog-writer on #<HASH:catalog-writer> resetkeys resetchannels db=0 ~catalog:* ~tmp:catalog:* -@all +@read +@write -@dangerous -@admin -@scripting +ping +hello +client|setname +client|setinfo | ||
| user catalog-reader on #<HASH:catalog-reader> resetkeys resetchannels db=0 %R~catalog:* %R~pricing:* -@all +@read -@dangerous -@scripting +ping +hello +client|setname +client|setinfo | ||
| # legacy-batch: was nopass ~* &* +@all. catalog:* is a placeholder until its real keyspace is known. | ||
| user legacy-batch on #<HASH:legacy-batch> resetkeys resetchannels db=0 ~catalog:* ~tmp:catalog:* -@all +@read +@write -@dangerous -@admin -@scripting +ping +hello +client|setname +client|setinfo | ||
|
|
||
| # --- humans --- | ||
| # oncall-sre: read-only. The old selectors were no-ops (root already had +@all). CONFIG SET / MONITOR go on a separate break-glass user. | ||
| user oncall-sre on #<HASH:oncall-sre> resetkeys resetchannels db=0 %R~* &* -@all +@read -@dangerous -@scripting +ping +hello +info +client|list +client|info +slowlog|get +latency|latest +memory|stats +dbsize +config|get +acl|whoami +acl|log | ||
| # support-readonly: root grants nothing; each selector sets its own db= (selectors default to alldbs). | ||
| # Notes selector no longer has FLUSHDB/FLUSHALL, KEYS/SCAN, UNLINK/GETDEL, FUNCTION/EVAL. | ||
| user support-readonly on #<HASH:support-readonly> resetkeys resetchannels resetdbs -@all (db=0 %R~customer:* %R~order:* +get +hgetall +lrange +ttl +type +ping +hello) (db=0 ~support:notes:* +@read +@write -@dangerous -@scripting -del -unlink -getdel +ping +hello) | ||
| ``` | ||
|
|
||
| Notice how much of that is repetition. `+ping +hello +client|setname +client|setinfo` shows up on every app user. `checkout-svc` and `catalog-writer` share command rules and differ mostly in key patterns. If apps shouldn't run `@scripting`, you edit every line, and any line you miss is a user with more access than you meant to give. | ||
|
|
||
| ## 9.2 has added Roles to make things easier | ||
|
|
||
| Valkey 9.2 has introduced ACL roles that allow you to set permissions to a role and then you can assign an individual to one or more roles. | ||
|
|
||
| A role holds the same kind of permissions a user does. | ||
|
|
||
| ``` | ||
| ACL SETROLE conn-basics resetchannels +ping +hello +client|setname +client|setinfo | ||
|
|
||
| ACL SETROLE catalog-read resetchannels db=0 %R~catalog:* %R~pricing:* +@read -@dangerous -@scripting | ||
|
|
||
| ACL SETROLE catalog-write resetchannels db=0 ~catalog:* ~tmp:catalog:* +@read +@write -@dangerous -@admin -@scripting | ||
|
|
||
| ACL SETROLE checkout-app db=0 ~checkout:* ~session:* %R~catalog:* &checkout-events:* +@read +@write +@pubsub -@dangerous -@admin -@scripting | ||
|
|
||
| ACL SETROLE support-ro resetchannels db=0 %R~customer:* %R~order:* +get +hgetall +lrange +ttl +type | ||
|
|
||
| ACL SETROLE support-notes resetchannels db=0 ~support:notes:* +@read +@write -@dangerous -@scripting -del -unlink -getdel | ||
|
|
||
| ACL SETROLE ops-readonly resetchannels db=0 %R~* &* +@read -keys -@scripting +info +client|list +client|info +slowlog|get +latency|latest +memory|stats +dbsize +config|get +acl|whoami +acl|log | ||
| ``` | ||
|
|
||
| Look at what the users would look like now. | ||
|
|
||
| ``` | ||
| # The same users from the first aclfile, now one line each. | ||
| # Each role= list replaces the long rule list that user had above. | ||
|
|
||
| user checkout-svc on #<HASH:checkout-svc> resetkeys resetchannels resetdbs -@all role=conn-basics,checkout-app | ||
|
|
||
| user catalog-writer on #<HASH:catalog-writer> resetkeys resetchannels resetdbs -@all role=conn-basics,catalog-write | ||
|
|
||
| user catalog-reader on #<HASH:catalog-reader> resetkeys resetchannels resetdbs -@all role=conn-basics,catalog-read | ||
|
|
||
| # legacy-batch: catalog:* is still a placeholder until its real keyspace is known. | ||
| user legacy-batch on #<HASH:legacy-batch> resetkeys resetchannels resetdbs -@all role=conn-basics,catalog-write | ||
|
|
||
| user oncall-sre on #<HASH:oncall-sre> resetkeys resetchannels resetdbs -@all role=conn-basics,ops-readonly | ||
|
|
||
| user support-readonly on #<HASH:support-readonly> resetkeys resetchannels resetdbs -@all role=conn-basics,support-ro,support-notes | ||
| ``` | ||
|
|
||
| Now you’re able to give access based on the role. This makes it clear what access each user has. | ||
|
|
||
| The `catalog-reader` doesn’t need write access to the catalog, and `support-readonly` doesn’t need access to checkout. | ||
|
|
||
| If you need to update one of the roles, run the `SETROLE` command again with the new permissions. This will automatically update the permissions for all the users with that role. This is a faster and cleaner way to adjust permissions for groups of users than having to do them one-by-one manually. | ||
|
|
||
| You can still apply a one-off role. New rules are applied on top of what the role already has, so to narrow a role add a negative rule (for example `ACL SETROLE catalog-write -@admin`). Every user holding the role picks up the change immediately, and Pub/Sub clients that lose access to their channels are disconnected. | ||
|
|
||
| The addition of roles is a departure from the traditional process. Instead of migrating all the permissions over at once, I recommend a slow consistent migration. Create roles for new permission groups. When you onboard a new user account, only apply roles. If you create a new role that can be applied, backport the roles to existing users, replacing the permissions they currently have. | ||
|
|
||
| Learn more about ACL Roles in the [ACL topic] and the [ACL Roles Command Page] on the Valkey Website. | ||
|
|
||
| [ACL topic]: https://valkey.io/topics/acl/#roles | ||
| [ACL Roles Command Page]: https://valkey.io/commands/acl-roles/ | ||
| [Valkey 9.2 Announcement]: https://valkey.io/blog/valkey-9.2-release/ | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.