From df57ca5edbb9492e4ff3a850f2e932f3102f45e1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 23 Nov 2023 11:22:23 +0100 Subject: [PATCH] Allow redis credentials be URL-decoded before passing them to connection --- CHANGELOG.md | 1 + composer.json | 6 +++--- config/autoload/cache.global.php | 1 + config/autoload/installer.global.php | 1 + module/Core/src/Config/EnvVars.php | 1 + module/Core/src/Model/DeviceType.php | 3 ++- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91273e5..40977d18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this This is important if you are running multiple Shlink instance on the same server, or they share the same Redis instance (even more so if they are on different versions). * [#1905](https://github.com/shlinkio/shlink/issues/1905) Add support for PHP 8.3. +* [#1927](https://github.com/shlinkio/shlink/issues/1927) Allow redis credentials be URL-decoded before passing them to connection. ### Changed * [#1799](https://github.com/shlinkio/shlink/issues/1799) RoadRunner/openswoole jobs are not run anymore for tasks that are actually disabled. diff --git a/composer.json b/composer.json index 8ccb6e14..c11ab753 100644 --- a/composer.json +++ b/composer.json @@ -41,16 +41,16 @@ "mezzio/mezzio-problem-details": "^1.13", "mezzio/mezzio-swoole": "^4.7", "mlocati/ip-lib": "^1.18", - "mobiledetect/mobiledetectlib": "^3.74", + "mobiledetect/mobiledetectlib": "^4.8", "pagerfanta/core": "^3.8", "php-middleware/request-id": "^4.1", "pugx/shortid-php": "^1.1", "ramsey/uuid": "^4.7", - "shlinkio/shlink-common": "dev-main#7d46772 as 5.7", + "shlinkio/shlink-common": "dev-main#e24ea7b as 5.7", "shlinkio/shlink-config": "dev-main#cde5d3b as 2.5", "shlinkio/shlink-event-dispatcher": "dev-main#35ccc0b as 3.1", "shlinkio/shlink-importer": "dev-main#d621b20 as 5.2", - "shlinkio/shlink-installer": "dev-develop#c505a19 as 8.6", + "shlinkio/shlink-installer": "dev-develop#0fde6fd as 8.6", "shlinkio/shlink-ip-geolocation": "dev-main#4a1cef8 as 3.3", "shlinkio/shlink-json": "dev-main#e5a111c as 1.1", "spiral/roadrunner": "^2023.2", diff --git a/config/autoload/cache.global.php b/config/autoload/cache.global.php index 94a9a183..30db2c0a 100644 --- a/config/autoload/cache.global.php +++ b/config/autoload/cache.global.php @@ -11,6 +11,7 @@ return (static function (): array { 'redis' => [ 'servers' => $redisServers, 'sentinel_service' => EnvVars::REDIS_SENTINEL_SERVICE->loadFromEnv(), + 'decode_credentials' => (bool) EnvVars::REDIS_DECODE_CREDENTIALS->loadFromEnv(false), ], ]; diff --git a/config/autoload/installer.global.php b/config/autoload/installer.global.php index e48b0ec7..77cb4439 100644 --- a/config/autoload/installer.global.php +++ b/config/autoload/installer.global.php @@ -32,6 +32,7 @@ return [ Option\Worker\TaskWorkerNumConfigOption::class, Option\Worker\WebWorkerNumConfigOption::class, Option\Redis\RedisServersConfigOption::class, + Option\Redis\RedisDecodeCredentialsConfigOption::class, Option\Redis\RedisSentinelServiceConfigOption::class, Option\Redis\RedisPubSubConfigOption::class, Option\UrlShortener\ShortCodeLengthOption::class, diff --git a/module/Core/src/Config/EnvVars.php b/module/Core/src/Config/EnvVars.php index c966043f..d6877eb9 100644 --- a/module/Core/src/Config/EnvVars.php +++ b/module/Core/src/Config/EnvVars.php @@ -20,6 +20,7 @@ enum EnvVars: string case CACHE_NAMESPACE = 'CACHE_NAMESPACE'; case REDIS_SERVERS = 'REDIS_SERVERS'; case REDIS_SENTINEL_SERVICE = 'REDIS_SENTINEL_SERVICE'; + case REDIS_DECODE_CREDENTIALS = 'REDIS_DECODE_CREDENTIALS'; case REDIS_PUB_SUB_ENABLED = 'REDIS_PUB_SUB_ENABLED'; case MERCURE_PUBLIC_HUB_URL = 'MERCURE_PUBLIC_HUB_URL'; case MERCURE_INTERNAL_HUB_URL = 'MERCURE_INTERNAL_HUB_URL'; diff --git a/module/Core/src/Model/DeviceType.php b/module/Core/src/Model/DeviceType.php index 3b6d9fcc..3cd3e132 100644 --- a/module/Core/src/Model/DeviceType.php +++ b/module/Core/src/Model/DeviceType.php @@ -12,7 +12,8 @@ enum DeviceType: string public static function matchFromUserAgent(string $userAgent): ?self { - $detect = new MobileDetect(userAgent: $userAgent); + $detect = new MobileDetect(); + $detect->setUserAgent($userAgent); return match (true) { // $detect->is('iOS') && $detect->isTablet() => self::IOS, // TODO To detect iPad only