0
0
Redisquery~5 mins

ACL rules and categories in Redis

Choose your learning style9 modes available
Introduction

ACL rules help control who can do what in Redis. They keep your data safe by limiting access.

You want to let some users read data but not change it.
You need to stop certain commands for security reasons.
You want to give different permissions to different users.
You want to organize permissions into groups for easier management.
Syntax
Redis
ACL SETUSER username [rule [rule ...]]
ACL DELUSER username
ACL LIST
ACL CAT [category]

Use ACL SETUSER to create or update a user with specific rules.

ACL CAT shows command categories to help assign permissions easily.

Examples
Create user 'alice' with password, full access to all commands and keys.
Redis
ACL SETUSER alice on >password ~* +@all
Create user 'bob' who can only read keys starting with 'cache:'.
Redis
ACL SETUSER bob on >secret ~cache:* +@read
Remove user 'alice' from Redis.
Redis
ACL DELUSER alice
Show all commands in the 'read' category.
Redis
ACL CAT @read
Sample Program

This creates a user 'guest' who can only read keys starting with 'public:'. Then it lists all users and their rules.

Redis
ACL SETUSER guest on nopass ~public:* +@read
ACL LIST
OutputSuccess
Important Notes

Rules starting with + allow commands or categories.

Rules starting with ~ limit key patterns the user can access.

Always test ACL rules with a test user before applying to real users.

Summary

ACL rules control user access to commands and keys in Redis.

Categories group commands to simplify permission settings.

Use ACL SETUSER to create or update users with rules.