Advertisement
Intermediate Redis, Redis Security & ACL

How do you create a Redis ACL user with permissions restricted to only specific commands and a specific pattern of keys?

Short answer

You use the ACL SETUSER command, specifying the username, enabling the user, setting a password, and then defining exactly which key patterns they can access using the tilde symbol and which commands they are allowed to run using plus signs for allowed commands and minus signs…

Save Redis mock interview
Advertisement
AModel answer
You use the ACL SETUSER command, specifying the username, enabling the user, setting a password, and then defining exactly which key patterns they can access using the tilde symbol and which commands they are allowed to run using plus signs for allowed commands and minus signs to explicitly deny others.
Example

ACL SETUSER app_user on >secure_password ~app:* +get +set +del -flushall

Real-world example
An application specific user is created with access limited to only keys prefixed with app, and permission to use get, set, and del, while being explicitly denied the ability to run the dangerous flushall command that would wipe the entire database.
Likely follow-ups
  • What happens if a user tries to run a command they have been explicitly denied?
  • How do you view the complete list of permissions currently assigned to a specific user?
Related topics