Skip to content

Commit c1b1e8c

Browse files
authored
Adds pub/sub channel patterns to ACL (redis#7993)
Fixes redis#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.
1 parent c85bf23 commit c1b1e8c

File tree

11 files changed

+442
-40
lines changed

11 files changed

+442
-40
lines changed

redis.conf

+26
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,11 @@ replica-priority 100
747747
# It is possible to specify multiple patterns.
748748
# allkeys Alias for ~*
749749
# resetkeys Flush the list of allowed keys patterns.
750+
# &<pattern> Add a glob-style pattern of Pub/Sub channels that can be
751+
# accessed by the user. It is possible to specify multiple channel
752+
# patterns.
753+
# allchannels Alias for &*
754+
# resetchannels Flush the list of allowed channel patterns.
750755
# ><password> Add this password to the list of valid password for the user.
751756
# For example >mypass will add "mypass" to the list.
752757
# This directive clears the "nopass" flag (see later).
@@ -820,6 +825,27 @@ acllog-max-len 128
820825
#
821826
# requirepass foobared
822827

828+
# New users are initialized with restrictive permissions by default, via the
829+
# equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it
830+
# is possible to manage access to Pub/Sub channels with ACL rules as well. The
831+
# default Pub/Sub channels permission if new users is controlled by the
832+
# acl-pubsub-default configuration directive, which accepts one of these values:
833+
#
834+
# allchannels: grants access to all Pub/Sub channels
835+
# resetchannels: revokes access to all Pub/Sub channels
836+
#
837+
# To ensure backward compatibility while upgrading Redis 6.0, acl-pubsub-default
838+
# defaults to the 'allchannels' permission.
839+
#
840+
# Future compatibility note: it is very likely that in a future version of Redis
841+
# the directive's default of 'allchannels' will be changed to 'resetchannels' in
842+
# order to provide better out-of-the-box Pub/Sub security. Therefore, it is
843+
# recommended that you explicitly define Pub/Sub permissions for all users
844+
# rather then rely on implicit default values. Once you've set explicit
845+
# Pub/Sub for all exisitn users, you should uncomment the following line.
846+
#
847+
# acl-pubsub-default resetchannels
848+
823849
# Command renaming (DEPRECATED).
824850
#
825851
# ------------------------------------------------------------------------

0 commit comments

Comments
 (0)