Review main Merged

91151[FEATURE] Support `username` for authentication in Redis cache backend

Sven Liebert CR +2 V +2 Normal +210 −10 updated 05/29/26, 02:37

Commit message

Starting with redis 6.0 authentication with `username & password` tuple
is supported, which was not reflected directly as configuration for the
`RedisBackend` cache backend of TYPO3.

Due to missing type on `RedisBackend->setPassword()` and the proeperty
`$password` instance maintainer configured the authentication tuple as
array for `password` as a workaround, which is quite etablished within
the TYPO3 community and hinders directly strict typing the places with
simple string type. Note that the annotated doc-block type `string` is
intentionally ignored for this working workaround.

This change provides now official support to configure `username` and
`password` for the redis connection of the cache backend while keeping
the workaround to configure a array as `password`, which is deprecated
now.

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

Review log 6274

Show 4049 earlier messages
  1. Sven Liebert uploaded patch set 1 10/18/25, 12:14

  2. 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

  3. Mathias Brodala commented on patch set 1 CR -1 10/18/25, 13:22

    RedisBackend.php:246

    This is a breaking change and should be documented. Alternatively explicitly allow string|array and throw a deprecation notice on array.
  4. Mathias Brodala commented on patch set 1 10/18/25, 13:24

    RedisBackend.php:244

    Not sure if we should also add the SensitiveParameter attribute here, while we're at it.
  5. Sven Liebert commented on patch set 1 10/18/25, 13:31

    RedisBackend.php:246 Reply

    I would do that breaking because we are before v14. Any thoughts about that?
  6. Sven Liebert commented on patch set 1 10/18/25, 14:02

    RedisBackend.php:246 Reply

    Will adjust it to deprecation to do a smoother change.
  7. Sven Liebert uploaded patch set 2 CR -1 V +1 10/18/25, 17:26

  8. Sven Liebert uploaded patch set 3 10/18/25, 17:29

  9. Sven Liebert commented on patch set 3 10/18/25, 17:30

    RedisBackend.php:244 Reply

    Done

    RedisBackend.php:246 Reply

    Done
  10. 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

  11. 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

  12. Sven Liebert uploaded patch set 4 V -1 10/18/25, 17:44

  13. 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

  14. 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)
  15. 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.
  16. Sven Liebert uploaded patch set 5 V +1 10/21/25, 12:39

  17. 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:)
  18. 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

  19. Mathias Brodala commented on patch set 5 10/21/25, 12:49

    Deprecation-107725-RedisCacheBackendAuthenticationWithUsernameAndPassword.rst:48

    We 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.
  20. 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
  21. Sven Liebert uploaded patch set 6 V +1 10/21/25, 13:01

  22. Sven Liebert updated the commit message in patch set 7 10/21/25, 13:02

  23. Sven Liebert commented on patch set 7 CR +1 V +1 10/21/25, 13:02

    Reply

    Done

    Deprecation-107725-RedisCacheBackendAuthenticationWithUsernameAndPassword.rst:48 Reply

    Done! :) I hope it's more clear now.
  24. Mathias Brodala voted on patch set 7 CR +1 10/21/25, 13:08

  25. 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

  26. 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

  27. Sven Liebert voted on patch set 7 CR 0 V 0 10/21/25, 13:21

  28. Josua Vogel voted on patch set 7 CR +1 V +1 10/21/25, 13:39

  29. Markus Klein commented on patch set 7 10/21/25, 14:09

    Please add this for the Redis Session Backend as well!
  30. Sven Liebert commented on patch set 7 10/21/25, 15:10

    Reply

    let‘s do that as follow up, ok?
  31. Sven Liebert commented on patch set 7 10/21/25, 18:06

    Reply

  32. 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
  33. Sven Liebert commented on patch set 7 10/22/25, 05:43

    Reply

    @mbrodala@pagemachine.de @j.vogel97@web.de any opinions?
  34. 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 😊
  35. 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:112

    I'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
  36. Sven Liebert commented on patch set 7 10/22/25, 13:44

    RedisBackend.php:112 Reply

    I 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?
  37. 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.
  38. Stefan Bürk commented on patch set 7 10/22/25, 14:08

    RedisBackend.php:112 Reply

    I 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).
  39. Sven Liebert commented on patch set 7 10/22/25, 18:25

    RedisBackend.php:112 Reply

    Like 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.
  40. Stefan Bürk commented on patch set 7 CR 0 10/22/25, 20:10

    RedisBackend.php:112 Reply

    K. Still not liking the array authentication array. Not feeling well with it. Removing the -1 for now and resolving the conversation.
  41. Sven Liebert uploaded patch set 8 CR +1 V +1 10/23/25, 19:23

  42. Sven Liebert commented on patch set 8 10/23/25, 19:24

    RedisBackend.php:112 Reply

    I built in your preferred way. I thought about it, and the solution is cleaner. Thank you :)
  43. 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

  44. Josua Vogel commented on patch set 8 10/24/25, 05:53

    RedisBackend.php:194

    Is the string cast really necessary? The properties are typed as string or null, and null was checked before
  45. Mathias Brodala commented on patch set 8 10/24/25, 06:46

    RedisBackend.php:191

    This 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
  46. Markus Klein commented on patch set 8 10/24/25, 06:49

    RedisBackend.php:194 Reply

    I'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']);
  47. Sven Liebert uploaded patch set 9 V +1 10/24/25, 12:27

  48. Sven Liebert commented on patch set 9 10/24/25, 12:28

    RedisBackend.php:191 Reply

    Done

    RedisBackend.php:194 Reply

    Done
  49. 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

  1. Josua Vogel voted on patch set 9 CR +1 V +1 10/24/25, 12:58

  2. Markus Klein voted on patch set 9 CR +1 V +1 10/24/25, 13:17

  3. Stefan Bürk commented on patch set 9 CR -1 10/24/25, 13:17

    Reviewing / On it ...
  4. Mathias Brodala commented on patch set 9 10/24/25, 13:59

    Amazing how much work goes into this one. 😄

    RedisBackend.php:277

    While others are reviewing: [ $this->username, $this->password ] = $password;
  5. 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:277 Reply

    will fix that after Stefans review :)
  6. Stefan Bürk uploaded patch set 10 CR +1 V +1 10/24/25, 15:56

  7. Stefan Bürk commented on patch set 10 10/24/25, 15:57

    RedisBackend.php:191

    Let'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:257

    Let'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:262

    Let'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:277 Reply

    Nope, 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.
  8. Stefan Bürk updated the commit message in patch set 11 10/24/25, 15:57

  9. Stefan Bürk commented on patch set 11 10/24/25, 15:58

    Reply

    Done

    RedisBackend.php:191 Reply

    Done

    RedisBackend.php:257 Reply

    Done

    RedisBackend.php:262 Reply

    Done
  10. Sven Liebert commented on patch set 11 CR +1 V +1 10/24/25, 16:03

    RedisBackend.php:277 Reply

    Acknowledged
  11. 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

  12. 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

  13. Josua Vogel voted on patch set 11 CR +1 V +1 10/24/25, 16:43

  14. Markus Klein commented on patch set 11 10/24/25, 18:13

    RedisBackend.php:240

    wrong phpdoc
  15. Stefan Bürk uploaded patch set 12 CR +1 V +1 10/24/25, 18:37

  16. Stefan Bürk commented on patch set 12 CR +1 V +1 10/24/25, 18:37

    RedisBackend.php:240 Reply

    Done
  17. 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

  18. Sven Liebert voted on patch set 12 CR +1 V +1 10/24/25, 22:58

  19. Josua Vogel voted on patch set 12 CR +1 V +1 10/25/25, 06:14

  20. Guido Schmechel voted on patch set 12 CR +1 V +1 10/25/25, 09:44

  21. Christian Kuhn voted on patch set 12 CR +1 10/25/25, 10:19

  22. Stefan Bürk voted on patch set 12 CR +2 V +2 10/25/25, 11:20

  23. Stefan Bürk merged patch set 13 10/25/25, 11:21

  24. Lina Wolf commented on patch set 13 11/01/25, 06:36

  25. Christian Kuhn commented on patch set 13 05/29/26, 02:37

    Reply

    Done