From ba16ba45f2635f173c2618d0cb63030d9b043a68 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 27 Oct 2025 10:16:57 +0100 Subject: [PATCH] Add support for redis credentials when using sentinels --- CHANGELOG.md | 4 ++++ composer.json | 4 ++-- config/autoload/cache.global.php | 2 ++ config/autoload/installer.global.php | 2 ++ module/Core/src/Config/EnvVars.php | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4e0e62f..277d6c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * [#2330](https://github.com/shlinkio/shlink/issues/2330) Add support to serve Shlink with FrankenPHP, by providing a worker script in `bin/frankenphp-worker.php`. +* [#2449](https://github.com/shlinkio/shlink/issues/2449) Add support to provide redis credentials separately when using redis sentinels, where provided servers are the sentinels and not the redis instances. + + For this, Shlink supports two new env ras / config options, as `REDIS_SERVERS_USER` and `REDIS_SERVERS_PASSWORD`. + ### Changed * *Nothing* diff --git a/composer.json b/composer.json index f04124d4..5576c622 100644 --- a/composer.json +++ b/composer.json @@ -43,11 +43,11 @@ "pagerfanta/core": "^3.8", "ramsey/uuid": "^4.7", "shlinkio/doctrine-specification": "^2.2", - "shlinkio/shlink-common": "^7.1", + "shlinkio/shlink-common": "dev-main#e8ccc5b as 7.2.0", "shlinkio/shlink-config": "^4.0", "shlinkio/shlink-event-dispatcher": "^4.3", "shlinkio/shlink-importer": "^5.6", - "shlinkio/shlink-installer": "^9.6", + "shlinkio/shlink-installer": "dev-develop#1f73ee9 as 9.7.0", "shlinkio/shlink-ip-geolocation": "^4.4", "shlinkio/shlink-json": "^1.2", "spiral/roadrunner": "^2025.1", diff --git a/config/autoload/cache.global.php b/config/autoload/cache.global.php index 6ae37de7..670a6a61 100644 --- a/config/autoload/cache.global.php +++ b/config/autoload/cache.global.php @@ -11,6 +11,8 @@ return (static function (): array { 'redis' => [ 'servers' => $redisServers, 'sentinel_service' => EnvVars::REDIS_SENTINEL_SERVICE->loadFromEnv(), + 'username' => EnvVars::REDIS_SERVERS_USER->loadFromEnv(), + 'password' => EnvVars::REDIS_SERVERS_PASSWORD->loadFromEnv(), ], ]; diff --git a/config/autoload/installer.global.php b/config/autoload/installer.global.php index 7f9e8900..a3918aff 100644 --- a/config/autoload/installer.global.php +++ b/config/autoload/installer.global.php @@ -33,6 +33,8 @@ return [ Option\Cache\CacheNamespaceConfigOption::class, Option\Redis\RedisServersConfigOption::class, Option\Redis\RedisSentinelServiceConfigOption::class, + Option\Redis\RedisServersUserConfigOption::class, + Option\Redis\RedisServersPasswordConfigOption::class, Option\Redis\RedisPubSubConfigOption::class, Option\UrlShortener\ShortCodeLengthOption::class, Option\Mercure\EnableMercureConfigOption::class, diff --git a/module/Core/src/Config/EnvVars.php b/module/Core/src/Config/EnvVars.php index bf5acc3e..8613b53f 100644 --- a/module/Core/src/Config/EnvVars.php +++ b/module/Core/src/Config/EnvVars.php @@ -41,6 +41,8 @@ enum EnvVars: string case CACHE_NAMESPACE = 'CACHE_NAMESPACE'; case REDIS_SERVERS = 'REDIS_SERVERS'; case REDIS_SENTINEL_SERVICE = 'REDIS_SENTINEL_SERVICE'; + case REDIS_SERVERS_USER = 'REDIS_SERVERS_USER'; + case REDIS_SERVERS_PASSWORD = 'REDIS_SERVERS_PASSWORD'; case REDIS_PUB_SUB_ENABLED = 'REDIS_PUB_SUB_ENABLED'; case MERCURE_ENABLED = 'MERCURE_ENABLED'; case MERCURE_PUBLIC_HUB_URL = 'MERCURE_PUBLIC_HUB_URL';