Skip to content

[NEW] ACL Role #3726

Closed

Description

@yang-z-o

Motivation

Valkey's ACL system supports fine-grained user-level permissions (commands, keys, channels, databases). However, there is no way to define a shared, reusable set of permissions and apply it to multiple users at once.

This becomes a real operational pain when:

  • Certificate-based authentication (Issue #1866) can create many users that logically belong to the same permission class.
  • Hundreds of users share the same permission policy (e.g. all "customer" users). Updating a shared policy (e.g. adding -@scripting for CVE remediation) requires updating every user individually.
  • No auditable structure. Without named roles, auditors must inspect every user individually to understand permission policies (e.g., no way to answer "which users have read-only access" without checking each one).

Prior discussions

Design

Core concepts

  1. A role is a named set of ACL rules. Including commands, keys, channels, and databases, but no passwords and flags. A role cannot be authenticated against directly.
  2. A user can belong to zero or more roles. The user holds pointers to its role selectors. During permission checks, the user's own selectors are checked first, then each role's selectors. All are evaluated with OR logic (consistent with existing selector semantics).
  3. Roles are flat. A role cannot contain another role. This avoids cyclic dependencies and keeps the model simple.
  4. Users can only add permissions on top of roles, not restrict them. Role selectors and user's own selectors are evaluated independently with OR logic. If any selector (role or user's own) allows a command, it is allowed. This is consistent with how multiple selectors already work in ACL V2.
  5. Role updates are zero-cost. Since users hold pointers to role objects, updating a role's selectors in-place is immediately visible to all members. No per-user rebuild needed.

New commands

Command / Syntax Description
ACL SETROLE <name> <rules...> Create or update a role. Rules use the same syntax as ACL SETUSER minus password/on/off.
ACL DELROLE <name> Delete a role. Fails if any users still reference it (safe deletion).
ACL GETROLE <name> Show role permissions (commands, keys, channels, selectors, members).
ACL ROLES List all roles.
ACL SETUSER <user> +@role:<name> Assign a role to a user.
ACL SETUSER <user> -@role:<name> Remove a role from a user.

ACL file format example

# Roles
role customer ~* &* +@all -@admin -@dangerous -@scripting
role readonly ~* &* +@read

# Users
user alice on >password +@role:customer
user bob on >password +@role:readonly
user carol on >password +@role:customer +EVAL

ACL GETUSER output changes

The ACL GETUSER response adds a new roles field. The commands, keys, and channels fields show the user's own root selector permissions. Role selectors are not shown inline but can be inspected via ACL GETROLE.

> ACL GETUSER carol
 1) "flags"
 2) 1) "on"
 3) "passwords"
 4) 1) "..."
 5) "commands"
 6) "+eval"                # user's own root selector
 7) "keys"
 8) ""
 9) "channels"
10) ""
11) "selectors"
12) (empty array)
13) "roles"                # NEW
14) 1) "customer"          # NEW

ACL GETROLE output

> ACL GETROLE customer
 1) "commands"
 2) "+@all -@admin -@dangerous -@scripting"
 3) "keys"
 4) "~*"
 5) "channels"
 6) "&*"
 7) "selectors"
 8) (empty array)
 9) "members"
10) 1) "alice"
11) 2) "carol"

ACL LIST output changes

> ACL LIST
1) "role customer ~* &* +@all -@admin -@dangerous -@scripting"
2) "user carol on #<hash> +@role:customer +eval"

Edge cases and considerations

  1. Deleting a role that has members: ACL DELROLE should fail with an error if any users reference the role. The operator must first remove users from the role. This prevents accidental permission changes.

  2. Circular references: Not possible since roles cannot contain other roles (flat model).

  3. Performance: Users hold pointers to role objects, so role updates are zero-cost (no per-user rebuild). The permission check adds one extra loop over role selectors, which is negligible for typical role counts.

  4. Role name validation: Role names follow the same rules as usernames (no spaces).

  5. Empty roles: Allowed. An empty role grants no permissions. This is useful for pre-creating roles before defining their rules.

  6. Reset behavior: ACL SETUSER alice reset clears role memberships along with everything else, consistent with resetting the user to defaults.

  7. Removing from a role: When a user is removed from a role (-@role:<name>), the role pointer is removed from the user's roles list. The role's selectors are no longer checked for that user.

  8. User cannot restrict role permissions: This is by design. Since role selectors are evaluated independently (OR logic), a user's deny rules on their own root selector do not override role grants. This is consistent with how multiple selectors already work in ACL V2.

Activity

  1. self-assigned this
    on May 15, 2026
  2. added
    enhancement
    on May 15, 2026
  3. madolson commented on Jun 1, 2026

    @madolson
    Member

    Weekly meeting notes: We are going to sync offline about this to try to figure out a more cohesive solution to solve the problem.

  4. added
    major-decision-pending
    on Jun 2, 2026
  5. hpatro commented on Jun 8, 2026

    @hpatro
    Contributor

    Sharing summary of internal slack discussion for public visibility:

    The team is aligning towards introducing a new resource called a role, which supports selectors (with multiple selectors allowed, consistent with how users work) and can be attached to one or more users.

    • When evaluating permissions, the role's selector is assessed alongside the user's own permissions with no concept of one superseding the other i.e. a command is permitted if it satisfies any of the applicable selector validations, whether from the role or the user. We could evaluate the role's selector first over user's selector. There is no difference in behaviour though.
    • Roles carry no password association.

    This is useful for applying a consistent set of permissions across multiple users, reducing duplication, though it is worth noting that roles cannot be used to enforce deny permissions (known limitation with multiple selectors as well).

    We can gauge if the above resource would be helpful to others and can build it for the community. @yang-z-o feel free to add if I missed anything.

  6. changed the title [-][NEW] ACL Group[/-] [+][NEW] ACL Role[/+] on Jun 8, 2026
  7. added a commit that references this issue on Sep 15, 2026
    6163991
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementmajor-decision-pending

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions