91151[FEATURE] Support `username` for authentication in Redis cache backend
Commit message
Review
-
Code review CR +2 Done
- Stefan Bürk +2
- Guido Schmechel +1
- Christian Kuhn +1
- Josua Vogel +1
- Sven Liebert +1
-
Verified V +2 Done
- Stefan Bürk +2
- Guido Schmechel +1
- Josua Vogel +1
- Sven Liebert +1
- core-ci +1 CI
Issues 1
Files 3
- typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php29+80 −10
- typo3/sysext/core/Documentation/Changelog/14.0/Deprecation-107725-RedisCacheBackendAuthenticationWithUsernameAndPassword.rst2new+90 −0
- typo3/sysext/core/Documentation/Changelog/14.0/Feature-107725-RedisCacheBackendAuthenticationWithUsernameAndPassword.rstnew+40 −0
Review log 6274
Show 4049 earlier messages
-
Sven Liebert uploaded patch set 1 10/18/25, 12:14
-
core-ci voted on patch set 1 V +1 10/18/25, 12:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86980
-
Mathias Brodala commented on patch set 1 CR -1 10/18/25, 13:22
-
Mathias Brodala commented on patch set 1 10/18/25, 13:24
RedisBackend.php:244Not sure if we should also add the SensitiveParameter attribute here, while we're at it. -
Sven Liebert commented on patch set 1 10/18/25, 13:31
RedisBackend.php:246ReplyI would do that breaking because we are before v14. Any thoughts about that? -
Sven Liebert commented on patch set 1 10/18/25, 14:02
RedisBackend.php:246ReplyWill adjust it to deprecation to do a smoother change. -
Sven Liebert uploaded patch set 2
CR -1V +110/18/25, 17:26 -
Sven Liebert uploaded patch set 3 10/18/25, 17:29
-
Sven Liebert commented on patch set 3 10/18/25, 17:30
RedisBackend.php:244ReplyDoneRedisBackend.php:246ReplyDone -
core-ci voted on patch set 2 V +1 10/18/25, 17:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86990
-
core-ci voted on patch set 3 V -1 10/18/25, 17:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86991
-
Sven Liebert uploaded patch set 4
V -110/18/25, 17:44 -
core-ci voted on patch set 4 V +1 10/18/25, 17:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86992
-
Josua Vogel commented on patch set 4 10/19/25, 08:20
IMO you need a deprecation (password as array) and a feature rst (added username) -
Mathias Brodala commented on patch set 4 10/20/25, 10:15
Looks good but [DEPRECATION] is not a thing AFAIK. This should be a FEATURE or TASK. -
Sven Liebert uploaded patch set 5
V +110/21/25, 12:39 -
Sven Liebert commented on patch set 5 10/21/25, 12:41
Reply
I hope now is all fine with RST files :)Reply
Should be done now:) -
core-ci voted on patch set 5 V +1 10/21/25, 12:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87184
-
Mathias Brodala commented on patch set 5 10/21/25, 12:49
Deprecation-107725-RedisCacheBackendAuthenticationWithUsernameAndPassword.rst:48We should be more verbose here and show Before/After snippets, especially because the Redis-internal keys are "user" and "pass" compared to "username" and "password" here. -
Mathias Brodala commented on patch set 5 10/21/25, 12:50
Sounds like we are caching authentication now. ;-) Better: > Support username for authentication in Redis cache backend -
Sven Liebert uploaded patch set 6
V +110/21/25, 13:01 -
Sven Liebert updated the commit message in patch set 7 10/21/25, 13:02
-
Sven Liebert commented on patch set 7 CR +1 V +1 10/21/25, 13:02
Reply
DoneDeprecation-107725-RedisCacheBackendAuthenticationWithUsernameAndPassword.rst:48ReplyDone! :) I hope it's more clear now. -
Mathias Brodala voted on patch set 7 CR +1 10/21/25, 13:08
-
core-ci voted on patch set 6 V +1 10/21/25, 13:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87188
-
core-ci voted on patch set 7 V +1 10/21/25, 13:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87189
-
Sven Liebert voted on patch set 7 CR 0 V 0 10/21/25, 13:21
-
Josua Vogel voted on patch set 7 CR +1 V +1 10/21/25, 13:39
-
Markus Klein commented on patch set 7 10/21/25, 14:09
Please add this for the Redis Session Backend as well! -
Sven Liebert commented on patch set 7 10/21/25, 15:10
Reply
let‘s do that as follow up, ok? -
Sven Liebert commented on patch set 7 10/21/25, 18:06
Reply
Here is the follow up: https://forge.typo3.org/issues/107802 -
Markus Klein commented on patch set 7 10/22/25, 05:16
Reply
I'd prefer to have all these Redis adoptions in a single patch. IMO no need to make it a separate commit and a separate rest file -
Sven Liebert commented on patch set 7 10/22/25, 05:43
Reply
@mbrodala@pagemachine.de @j.vogel97@web.de any opinions? -
Josua Vogel commented on patch set 7 10/22/25, 06:09
Reply
I think that's a matter of personal preference. I wouldn't extend this MR; it should only apply to the cache backend. The follow-up would then be to adjust the session backend. It's better to merge manageable MRs quickly and move forward 😊 -
Stefan Bürk commented on patch set 7 CR -1 10/22/25, 13:26
Reply
Would be fine to have that in one change and one restfile (one per feature one per deprecation). But having that in dedicated changes is also fine. In case of regression would be easier to revert one instead of two changes.RedisBackend.php:112I'm not a fan of saving this now as a array just with a array shape here, special for the grace period the type is not ensured. Beside that, php-redis is reading the passed array for `$redis->auth([/*..*/]) positional pased and not from associative keys, which is **not** ensured. For example following configuration: ``` [ // ... 'password' => 'some-password', 'username' =>> 'user-name', // ... ] ``` would first call `setPassword()` and than `setUserName()` ending up with ``` $this->authentication = [ 'pass' => 'some-password', 'user' => 'user-name', ]; ``` and having user/pass in wrong order passed to the auth method. TBH not checked that against a redis instance if that makes a difference, I'm mention that purely based on the documentation of `php-redis`: ``` Redis|bool auth(mixed $credentials) Authenticate a Redis connection after its been established. $redis->auth('password'); $redis->auth(['password']); $redis->auth(['username', 'password']); Parameters mixed $credentials A string password, or an array with one or two string elements. ``` I would therefore prefere to: * Have dedicated properties (typed) for user and password ``` protected ?string $username = null; protected ?string $password = null; ``` * Compose the auth array correctly before calling the auth() method to have ensured array based on the fact if username is set or not. ``` $authentication=[]; if ($this->username !== null) { $authentication[] = $this->username; } if ($this->password !== null) { $authentication[] = $this->password; } $this->redis->auth($authentication) ``` eventually having a private method to return the value for the authentication: ``` private function getAuthentication(): array|string { if ($this->username !== null) { return [(string)$this->username, (string)$this->password]; } return (string)$this->password; } ``` * `setPassword(array|string)` in case of an array we may want to check for `user/pass` keyes .. or index based to extract them properly and also set the "user" in that case. ``` public function setUsername(string $username): void { if (is_string($password)) { $this->password = $password; return; } if (isset($password['user']) && isset($password['pass'])) { $this->username = $password['user']; $this->password = $password['password'] } elseif (count($password) === 2) { $this->username = $password[array_first_key($password)]; $this->password = $password[array_last_key($password)]; } else { throw new \RuntimeException( 'Cannot extract username and password from workaround array as password', 1761139334, ); } } ``` See: * https://redis.io/docs/latest/commands/auth/ * https://phpredis.github.io/phpredis/Redis.html#method_auth -
Sven Liebert commented on patch set 7 10/22/25, 13:44
RedisBackend.php:112ReplyI will check if the order of user and pass is relevant. Would you accept that in that case? I personally think the approach here is too much complex code. The if-stuff in setUsername is massive and then not necessary. I was fine with do it breaking typed correctly, but I understand the deprecation approach. So the main question is: Would you accept this code if the order is irrelevant for redis authentication? -
Markus Klein commented on patch set 7 10/22/25, 13:49
Reply
The sole reason, I like to have this in one change, is the mess I had to cleanup over the years because these two diverted. Something is always going to happen if we split this. (life lesson :-)) Of course, I'm not the one who decides; just my thoughts. -
Stefan Bürk commented on patch set 7 10/22/25, 14:08
RedisBackend.php:112ReplyI would not block it. But still I personally don't like the authentication array here ... not sure if I would merge it. Need to rethink that (later). -
Sven Liebert commented on patch set 7 10/22/25, 18:25
RedisBackend.php:112ReplyLike I thought and README of php-redis said, the position is irrelevant for associative array. The order of calling setPassword and setUsername is irrelevant. I would like if php-redis would provide APIs to set username and password directly before authentication, but we need this ugly array at any point. -
Stefan Bürk commented on patch set 7 CR 0 10/22/25, 20:10
RedisBackend.php:112ReplyK. Still not liking the array authentication array. Not feeling well with it. Removing the -1 for now and resolving the conversation. -
Sven Liebert uploaded patch set 8
CR +1V +110/23/25, 19:23 -
Sven Liebert commented on patch set 8 10/23/25, 19:24
RedisBackend.php:112ReplyI built in your preferred way. I thought about it, and the solution is cleaner. Thank you :) -
core-ci voted on patch set 8 V +1 10/23/25, 19:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87440
-
Josua Vogel commented on patch set 8 10/24/25, 05:53
RedisBackend.php:194Is the string cast really necessary? The properties are typed as string or null, and null was checked before -
Mathias Brodala commented on patch set 8 10/24/25, 06:46
RedisBackend.php:191This can always be an array. If there is only a password ["password"] is valid, see https://github.com/phpredis/phpredis?tab=readme-ov-file#auth -
Markus Klein commented on patch set 8 10/24/25, 06:49
RedisBackend.php:194ReplyI'd go for the more speaking version mentioned here: https://github.com/phpredis/phpredis/?tab=readme-ov-file#auth /* You can also use an associative array specifying user and pass */ $redis->auth(['user' => 'phpredis', 'pass' => 'phpredis']); -
Sven Liebert uploaded patch set 9
V +110/24/25, 12:27 -
Sven Liebert commented on patch set 9 10/24/25, 12:28
RedisBackend.php:191ReplyDoneRedisBackend.php:194ReplyDone -
core-ci voted on patch set 9 V +1 10/24/25, 12:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87495
-
Josua Vogel voted on patch set 9 CR +1 V +1 10/24/25, 12:58
-
Markus Klein voted on patch set 9 CR +1 V +1 10/24/25, 13:17
-
Stefan Bürk commented on patch set 9 CR -1 10/24/25, 13:17
Reviewing / On it ... -
Mathias Brodala commented on patch set 9 10/24/25, 13:59
Amazing how much work goes into this one. 😄RedisBackend.php:277While others are reviewing: [ $this->username, $this->password ] = $password; -
Sven Liebert commented on patch set 9 10/24/25, 14:16
Reply
Thats the reason why I wanted to do Redis Session handler afterwards 😄RedisBackend.php:277Replywill fix that after Stefans review :) -
Stefan Bürk uploaded patch set 10
CR +1V +110/24/25, 15:56 -
Stefan Bürk commented on patch set 10 10/24/25, 15:57
RedisBackend.php:191Let's return `array|string|null` here and change the method code to a match() function along with adding comments to explain the cases. Makes reading in the future more fun.RedisBackend.php:257Let's add a `@todo` to remember that with TYPO3 v15 the signature needs to be changed (breaking) along with the compat for array as $password.RedisBackend.php:262Let's change the check and order, which allows us to mark the if-condition as todo to be removed completly with TYPO3 v15. ANd let's move the deprecated handling code into a dedicated private method making the regnonizable code to be removed smaller in this method.RedisBackend.php:277ReplyNope, keep it the way it is. I had reasons to suggest that variant. ``` [ $this->username, $this->password ] = $password; ``` This only works without issues ifit is a list-indexed array starting with index 0 and having 2 or more elements. Otherwise it would fail, for example if other associative keys are used, or a array where elements has been unset and the index order does not match, etc ... see https://3v4l.org/BIN1a for examples and the outcome. -
Stefan Bürk updated the commit message in patch set 11 10/24/25, 15:57
-
Stefan Bürk commented on patch set 11 10/24/25, 15:58
Reply
DoneRedisBackend.php:191ReplyDoneRedisBackend.php:257ReplyDoneRedisBackend.php:262ReplyDone -
Sven Liebert commented on patch set 11 CR +1 V +1 10/24/25, 16:03
RedisBackend.php:277ReplyAcknowledged -
core-ci voted on patch set 10 V +1 10/24/25, 16:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87521
-
core-ci voted on patch set 11 V +1 10/24/25, 16:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87522
-
Josua Vogel voted on patch set 11 CR +1 V +1 10/24/25, 16:43
-
Markus Klein commented on patch set 11 10/24/25, 18:13
RedisBackend.php:240wrong phpdoc -
Stefan Bürk uploaded patch set 12
CR +1V +110/24/25, 18:37 -
Stefan Bürk commented on patch set 12 CR +1 V +1 10/24/25, 18:37
RedisBackend.php:240ReplyDone -
core-ci voted on patch set 12 V +1 10/24/25, 18:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87531
-
Sven Liebert voted on patch set 12 CR +1 V +1 10/24/25, 22:58
-
Josua Vogel voted on patch set 12 CR +1 V +1 10/25/25, 06:14
-
Guido Schmechel voted on patch set 12 CR +1 V +1 10/25/25, 09:44
-
Christian Kuhn voted on patch set 12 CR +1 10/25/25, 10:19
-
Stefan Bürk voted on patch set 12 CR +2 V +2 10/25/25, 11:20
-
Stefan Bürk merged patch set 13 10/25/25, 11:21
-
Lina Wolf commented on patch set 13 11/01/25, 06:36
Please review documentation patch: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/6156 -
Christian Kuhn commented on patch set 13 05/29/26, 02:37
Reply
Done
RedisBackend.php:246