An ACL system helps control who can do what in a database. It keeps data safe by giving permissions only to the right users.
0
0
ACL system for user permissions in Redis
Introduction
When you want to let some users read data but not change it.
When you need to stop unauthorized users from deleting important information.
When different users have different roles, like admin or guest.
When you want to track who can run certain commands in Redis.
When you want to quickly change user permissions without restarting Redis.
Syntax
Redis
ACL SETUSER username [rule [rule ...]] ACL DELUSER username ACL LIST ACL GETUSER username
ACL SETUSER creates or updates a user with specific permissions.
Rules include commands allowed (+), commands denied (-), keys allowed (~), and passwords (>).
Examples
Creates user 'alice' who can run GET and SET commands on all keys, with password 'password123'.
Redis
ACL SETUSER alice on >password123 +get +set ~*User 'guest' can only run GET on keys starting with 'public:', cannot run SET or DEL.
Redis
ACL SETUSER guest on +get ~public:* -set -delDeletes the user 'guest' from the ACL system.
Redis
ACL DELUSER guest
Shows all users and their permissions.
Redis
ACL LIST
Sample Program
This creates a user 'bob' with password 'bobpass'. Bob can run GET and SET commands only on keys starting with 'data:'. Then it shows Bob's permissions.
Redis
ACL SETUSER bob on >bobpass +get +set ~data:*
ACL GETUSER bobOutputSuccess
Important Notes
Always set strong passwords for users to keep your data safe.
Use ACL LIST to review all users and their permissions regularly.
Remember that permissions are additive; if you deny a command explicitly, it overrides allowed commands.
Summary
ACL controls who can do what in Redis.
Use ACL SETUSER to create or update users with specific permissions.
Check permissions with ACL GETUSER and list all users with ACL LIST.