Repository: goauthentik/authentik

Issue:
Redis Username is ignored
**Describe the bug**
I cannot connect to AWS MemoryDB with a user since I specifying the redis username with `AUTHENTIK_REDIS__USERNAME` has no effect.

**To Reproduce**
Steps to reproduce the behavior:

Set the env var `AUTHENTIK_REDIS__USERNAME` to some non-empty value.
I'm using this with tls, so set `AUTHENTIK_REDIS__TLS: "true"`
For testing, set `AUTHENTIK_REDIS__HOST` to a bogus value like `this-does-not-exist.example.com`
Start the worker or the server, and see the error in the logs. It will contain the redis_url which has no username specified.

Looking at [settings.py](https://github.com/goauthentik/authentik/blob/main/authentik/root/settings.py#L190), I don't see the username being added anywhere.

**Expected behavior**
I expect the username to be part of the connection, to enable [ACLs](https://redis.io/docs/management/security/acl/) which are needed for MemoryDB

**Screenshots**
N/A

**Logs**
Output of kubectl logs

```jsonl
{"event": "Redis Connection failed, retrying... (invalid username-password pair or user is disabled.)", "level": "info", "logger": "authentik.lib.config", "timestamp": 1705375094.3045342, "redis_url": "rediss://:secretpassword@clustercfg.test-cluster.md65rt.memorydb.ca-central-1.amazonaws.com:6379/0"}
{"event": "Redis Connection failed, retrying... (invalid username-password pair or user is disabled.)", "level": "info", "logger": "authentik.lib.config", "timestamp": 1705375095.347511, "redis_url": "rediss://:secretpassword@clustercfg.test-cluster.md65rt.memorydb.ca-central-1.amazonaws.com:6379/0"}
{"event": "Redis Connection failed, retrying... (invalid username-password pair or user is disabled.)", "level": "info", "logger": "authentik.lib.config", "timestamp": 1705375096.385973, "redis_url": "rediss://:secretpassword@clustercfg.test-cluster.md65rt.memorydb.ca-central-1.amazonaws.com:6379/0"}
```


**Version and Deployment (please complete the following information):**

-   authentik version:2023.10.6
-   Deployment: helm



Discussion:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Resolving patch:
diff --git a/authentik/root/settings.py b/authentik/root/settings.py
--- a/authentik/root/settings.py
+++ b/authentik/root/settings.py
@@ -196,8 +196,10 @@
     _redis_protocol_prefix = "rediss://"
     _redis_celery_tls_requirements = f"?ssl_cert_reqs={CONFIG.get('redis.tls_reqs')}"
 _redis_url = (
-    f"{_redis_protocol_prefix}:"
-    f"{quote_plus(CONFIG.get('redis.password'))}@{quote_plus(CONFIG.get('redis.host'))}:"
+    f"{_redis_protocol_prefix}"
+    f"{quote_plus(CONFIG.get('redis.username'))}:"
+    f"{quote_plus(CONFIG.get('redis.password'))}@"
+    f"{quote_plus(CONFIG.get('redis.host'))}:"
     f"{CONFIG.get_int('redis.port')}"
 )
 
diff --git a/lifecycle/system_migrations/to_0_13_authentik.py b/lifecycle/system_migrations/to_0_13_authentik.py
--- a/lifecycle/system_migrations/to_0_13_authentik.py
+++ b/lifecycle/system_migrations/to_0_13_authentik.py
@@ -116,6 +116,7 @@ def run(self):
                     host=CONFIG.get("redis.host"),
                     port=6379,
                     db=db,
+                    username=CONFIG.get("redis.username"),
                     password=CONFIG.get("redis.password"),
                 )
                 redis.flushall()


Test patch: