Support Redis ACL's

Created on 30 June 2022, almost 3 years ago
Updated 20 August 2024, 8 months ago

Problem/Motivation

This module supports Redis's legacy password protection mode (controlled via the requirepass directive in redis.conf) but does not support ACL's. As of Redis 6+ ACL's are the preferred way to protect a Redis instance and provide control over what commands or keys a client has access to. This is especially useful when securing a Redis server shared by multiple applications.

Note that the legacy password protection still works in Redis 6+ and is compatible with ACL's: under the hood it just sets an ACL rule for the default user (see documentation).

Both PhpRedis and Predis support ACLs (see here and here), so the work involved to make this module support ACLs is not huge.

Proposed resolution

Introduce a new setting $settings['redis.connection']['username'] and provide integration for both PhpRedis and Predis. Attached is a proposed patch.

1. Predis

Predis just requires an additional parameter username (documentation here).

What the module currently does (legacy password protection):

$client = new Predis\Client([
  ...
  'password' => 'mypassword',
]);

What it needs to do to support ACL's (only if a username was provided):

$client = new Predis\Client([
  ...
  'password' => 'mypassword',
  'username' => 'myusername',
]);

2. PhpRedis

PhpRedis expects the credentials to be passed as an array instead of a string (documentation here).

What the module currently does (legacy password protection):

$redis->auth('mypassword');

What it needs to do to support ACL's (only if a username was provided):

$redis->auth(['myusername', 'mypassword']);
Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇨🇦Canada fengtan Montreal, Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024