ACL SETUSER

Since 1.1.0ACL

Syntax

ACL SETUSER
  • Subcommand of ACL

Creates the user username, or changes it, by applying rules from left to right. A user that does not exist starts with no permissions, disabled.

Rules

RuleEffect
on, offEnable or disable the user. A disabled user cannot log in.
>password, <passwordAdd or remove a password. A user can have several.
#sha256, !sha256Add or remove a password by its SHA-256 hash.
nopass, resetpassAllow any password, or remove every password.
+command, -commandAllow or deny a command; command|subcommand for one subcommand.
+@category, -@categoryAllow or deny a category of commands; ACL CAT lists them. +@all and -@all are every command.
~patternAllow reading and writing keys matching a glob-style pattern; ~* or allkeys for all.
%R~pattern, %W~pattern, %RW~patternAllow only reading, only writing, or both, for matching keys.
&patternAllow publishing and subscribing to matching channels; allchannels for all. A user with none cannot use pub/sub.
resetkeys, resetchannelsRemove every key, or channel, pattern.
resetBack to a new user's state.

Command rules apply in order, so the last one that names a command decides for it: -@all +get +set allows only GET and SET. With an ACL file configured (aclfile), the change is saved to it at once.

Reply

  • OK.
  • ERR Error in ACL SETUSER modifier '...': Syntax error for a rule that is not one; nothing changes.

Examples

> ACL SETUSER alice on >s3cret ~cache:* &news -@all +get +set
OK
> ACL SETUSER bob on >pw %R~* -@all +@read
OK
> ACL SETUSER dave nosuchrule
(error) ERR Error in ACL SETUSER modifier 'nosuchrule': Syntax error

Then, logged in as alice:

> AUTH alice s3cret
OK
> SET cache:1 v
OK
> SET other v
(error) NOPERM User alice has no permissions to access the 'other' key
> DEL cache:1
(error) NOPERM User alice has no permissions to run the 'del' command