21 Commits

Author SHA1 Message Date
Itamar Haber
fe6d04a872 Adds pub/sub channel patterns to ACL (#7993)
Fixes #7923.

This PR appropriates the special `&` symbol (because `@` and `*` are taken),
followed by a literal value or pattern for describing the Pub/Sub patterns that
an ACL user can interact with. It is similar to the existing key patterns
mechanism in function (additive) and implementation (copy-pasta). It also adds
the allchannels and resetchannels ACL keywords, naturally.

The default user is given allchannels permissions, whereas new users get
whatever is defined by the acl-pubsub-default configuration directive. For
backward compatibility in 6.2, the default of this directive is allchannels but
this is likely to be changed to resetchannels in the next major version for
stronger default security settings.

Unless allchannels is set for the user, channel access permissions are checked
as follows :
* Calls to both PUBLISH and SUBSCRIBE will fail unless a pattern matching the
  argumentative channel name(s) exists for the user.
* Calls to PSUBSCRIBE will fail unless the pattern(s) provided as an argument
  literally exist(s) in the user's list.

Such failures are logged to the ACL log.

Runtime changes to channel permissions for a user with existing subscribing
clients cause said clients to disconnect unless the new permissions permit the
connections to continue. Note, however, that PSUBSCRIBErs' patterns are matched
literally, so given the change bar:* -> b*, pattern subscribers to bar:* will be
disconnected.

Notes/questions:
* UNSUBSCRIBE, PUNSUBSCRIBE and PUBSUB remain unprotected due to lack of reasons
  for touching them.
2020-12-01 14:21:39 +02:00
Madelyn Olson
2eae7756fd Further improved ACL algorithm for picking categories 2020-10-28 10:01:20 -07:00
Madelyn Olson
abe416c5f2 Fixed excessive categories being displayed from acls (#7889) 2020-10-07 22:09:09 -07:00
Wang Yuan
3085577c09 Don't write replies if close the client ASAP (#7202)
Before this commit, we would have continued to add replies to the reply buffer even if client
output buffer limit is reached, so the used memory would keep increasing over the configured limit.
What's more, we shouldn’t write any reply to the client if it is set 'CLIENT_CLOSE_ASAP' flag
because that doesn't conform to its definition and we will close all clients flagged with
'CLIENT_CLOSE_ASAP' in ‘beforeSleep’.

Because of code execution order, before this, we may firstly write to part of the replies to
the socket before disconnecting it, but in fact, we may can’t send the full replies to clients
since OS socket buffer is limited. But this unexpected behavior makes some commands work well,
for instance ACL DELUSER, if the client deletes the current user, we need to send reply to client
and close the connection, but before, we close the client firstly and write the reply to reply
buffer. secondly, we shouldn't do this despite the fact it works well in most cases.

We add a flag 'CLIENT_CLOSE_AFTER_COMMAND' to mark clients, this flag means we will close the
client after executing commands and send all entire replies, so that we can write replies to
reply buffer during executing commands, send replies to clients, and close them later.

We also fix some implicit problems. If client output buffer limit is enforced in 'multi/exec',
all commands will be executed completely in redis and clients will not read any reply instead of
partial replies. Even more, if the client executes 'ACL deluser' the using user in 'multi/exec',
it will not read the replies after 'ACL deluser' just like before executing 'client kill' itself
in 'multi/exec'.

We added some tests for output buffer limit breach during multi-exec and using a pipeline of
many small commands rather than one with big response.

Co-authored-by: Oran Agra <oran@redislabs.com>
2020-09-24 16:01:41 +03:00
杨博东
ce14668316 Tests: Add aclfile load and save tests (#7765)
improves test coverage
2020-09-09 17:13:35 +03:00
WuYunlong
e5166eccee Fix command help for unexpected options (#7476) 2020-07-15 12:38:22 +03:00
antirez
bbbd16a90d Regression test for #7011. 2020-03-20 12:52:06 +01:00
antirez
f1518f63b1 ACL LOG: make max log entries configurable. 2020-02-04 13:19:40 +01:00
antirez
da054f14f0 ACL LOG: test for AUTH reason. 2020-02-04 12:58:48 +01:00
antirez
8185f2b6ce ACL LOG: implement a few basic tests. 2020-01-30 11:14:13 +01:00
antirez
6118989790 ACLs: change hashed passwords opcode to also remove them.
Related to PR #6405
2019-09-30 18:28:45 +02:00
Madelyn Olson
364c8601e3 Allowed passing in of password hash and fixed config rewrite 2019-09-30 17:57:49 +02:00
antirez
1a505a3ba9 ACL: Fix memory leak in ACLResetSubcommandsForCommand().
This commit fixes bug reported at #5998. Thanks to @tomcat1102.
2019-04-08 18:08:37 +02:00
antirez
b364f3fc21 ACL: regression test for #5998. 2019-04-08 18:06:50 +02:00
antirez
1db503c865 Acl: Test: check command rules synthesis. 2019-01-30 12:01:37 +01:00
antirez
c4f8e91a6c ACL: Test: check subcommands (test fails). 2019-01-28 18:29:22 +01:00
antirez
0f7c574f9f ACL: Test: nopass user flag, commands/groups +/- rules. 2019-01-28 12:40:07 +01:00
antirez
3cf816c703 ACL: Test: check default behavior and keys ACLs. 2019-01-28 12:33:18 +01:00
antirez
a791d5a7a1 ACL: Test: check passwords validity and removal. 2019-01-28 12:06:25 +01:00
antirez
f94c5c77b0 ACL: Test: enabled/disabled user. 2019-01-28 11:44:10 +01:00
antirez
18b2257fda ACL: create unit test. 2019-01-28 11:39:58 +01:00