From 5b932e390ec39c57d5280e0fa531fbd7202d49ed Mon Sep 17 00:00:00 2001
From: Hagen <2806328+derhagen@users.noreply.github.com>
Date: Sat, 11 Jan 2025 19:22:09 +0100
Subject: [PATCH] Add REDIS_HOST_USER variable to specify a redis user (#2359)

Signed-off-by: hagene <hagene@uio.no>
---
 .config/redis.config.php | 4 ++++
 README.md                | 1 +
 2 files changed, 5 insertions(+)

diff --git a/.config/redis.config.php b/.config/redis.config.php
index a5b13da6f..2069812f4 100644
--- a/.config/redis.config.php
+++ b/.config/redis.config.php
@@ -14,4 +14,8 @@
   } elseif (getenv('REDIS_HOST')[0] != '/') {
     $CONFIG['redis']['port'] = 6379;
   }
+
+  if (getenv('REDIS_HOST_USER') !== false) {
+    $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER');
+  }
 }
diff --git a/README.md b/README.md
index 6745faa3d..6fdd5ec95 100644
--- a/README.md
+++ b/README.md
@@ -236,6 +236,7 @@ To use Redis for memory caching as well as PHP session storage, specify the foll
 
 - `REDIS_HOST` (not set by default) Name of Redis container
 - `REDIS_HOST_PORT` (default: `6379`) Optional port for Redis, only use for external Redis servers that run on non-standard ports.
+- `REDIS_HOST_USER` (not set by default) Optional username for Redis, only use for external Redis servers that require a user.
 - `REDIS_HOST_PASSWORD` (not set by default) Redis password
 
 Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html) for more information.