>_ IzzyLab

Hands-on task

This task is step 7 of the course “Redis in production”

An ACL user just for the cache

medium~15 min

The application needs its own Redis login with minimal privileges. Create an ACL user:

  • name app, password app-secret, user enabled;
  • access only to keys matching cache:*;
  • only the GET, SET, DEL and PING commands allowed — FLUSHALL, CONFIG, KEYS and everything else forbidden.

The user must survive a Redis restart: keep the ACLs in a separate file /etc/redis/users.acl, included in /etc/redis/redis.conf with the aclfile directive. Don't touch the default user.

What you'll practise:
  • redis
  • ACL
  • ACL SETUSER
  • aclfile
  • ACL SAVE
  • principle of least privilege

Topic breakdown

Since Redis 6 access is controlled with ACLs: each user has a password, a set of allowed commands (+get, -@all, +@read…) and key patterns (~cache:*) it may access. An application that only needs a cache should not be able to run FLUSHALL or CONFIG SET — that way a leaked password or a bug in the code won't destroy all the data. Users created with ACL SETUSER live in memory: to survive a restart they are kept in a separate file (aclfile) and saved there with ACL SAVE, while ACL LOAD rereads the file without a restart.

What's checked

  1. app logs in with the password and writes/reads cache:x
  2. app can't see keys outside cache:*
  3. app can't run FLUSHALL, CONFIG and KEYS
  4. app can't run commands other than GET/SET/DEL/PING
  5. ACLs stored in /etc/redis/users.acl
  6. user app survives a restart (the check restarts Redis)

What it looks like