An ACL system helps control who can do what in a database. It keeps data safe by giving permissions only to the right users.
ACL system for user permissions in 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 (>).
ACL SETUSER alice on >password123 +get +set ~*ACL SETUSER guest on +get ~public:* -set -delACL DELUSER guest
ACL LIST
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.
ACL SETUSER bob on >bobpass +get +set ~data:*
ACL GETUSER bobAlways 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.
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.
Practice
Solution
Step 1: Understand ACL purpose
ACL in Redis is designed to manage user permissions, controlling what commands and keys users can access.Step 2: Compare options
Options B, C, and D describe unrelated Redis features like performance and backup, not ACL.Final Answer:
To control which users can perform specific commands and access keys -> Option BQuick Check:
ACL controls permissions = A [OK]
- Confusing ACL with performance tuning
- Thinking ACL manages backups
- Assuming ACL monitors server stats
Solution
Step 1: Recall Redis ACL command syntax
The correct command to create or update a user isACL SETUSERfollowed by username and permissions.Step 2: Check options
Only ACL SETUSER username on >password ~keys +commands usesACL SETUSER. Others use invalid commands like CREATEUSER, ADDUSER, UPDATEUSER which do not exist in Redis ACL.Final Answer:
ACL SETUSER username on >password ~keys +commands -> Option DQuick Check:
Use ACL SETUSER to set permissions [OK]
- Using non-existent ACL commands like CREATEUSER
- Confusing SETUSER with other verbs
- Missing required syntax parts like 'on' or '>'
ACL SETUSER alice on >mypassword ~cache:* +get +set, what permissions does user 'alice' have?Solution
Step 1: Analyze ACL SETUSER command parts
'on' enables the user, '>mypassword' sets password, '~cache:*' limits keys to those starting with 'cache:', '+get +set' allows only GET and SET commands.Step 2: Interpret permissions
User 'alice' can only run GET and SET commands on keys matching 'cache:*'. Other commands or keys are denied.Final Answer:
User 'alice' can only run GET and SET commands on keys starting with 'cache:' -> Option CQuick Check:
Commands + keys limited = A [OK]
- Assuming all commands are allowed
- Ignoring key pattern restrictions
- Thinking user is disabled without 'off'
ACL SETUSER bob on >secret +@all but Bob still cannot execute commands. What is the likely problem?Solution
Step 1: Check user status and permissions
'on' enables Bob, '+@all' grants all command categories, and '>secret' sets password correctly.Step 2: Identify why commands fail
If Bob cannot run commands, likely he did not authenticate with the password, so Redis denies access despite permissions.Final Answer:
Bob's client did not authenticate with the password -> Option AQuick Check:
Authentication required after ACL SETUSER [OK]
- Forgetting to authenticate after setting password
- Assuming 'on' disables user if missing
- Thinking '+@all' is invalid
INFO command and read keys starting with stats:. Which command correctly sets this up?Solution
Step 1: Understand command requirements
User 'reporter' needs only the INFO command and access to keys starting with 'stats:'.Step 2: Evaluate options
ACL SETUSER reporter on >pass123 ~stats:* +info: ACL SETUSER reporter on >pass123 ~stats:* +info grants only the INFO command on keys starting with 'stats:'. ACL SETUSER reporter on >pass123 ~stats:* +get +info incorrectly grants +get which is not required. ACL SETUSER reporter on >pass123 ~stats:* +@read grants all read commands (+@read), which is too broad. ACL SETUSER reporter on >pass123 ~stats:* +get misses +info, so cannot run INFO command.Final Answer:
ACL SETUSER reporter on >pass123 ~stats:* +info -> Option AQuick Check:
Only INFO command + key permissions = C [OK]
- Granting command categories instead of specific commands
- Missing +info for INFO command
- Forgetting to enable user with 'on'
Ready to prove it?
Pass the test and this pattern moves unknown
