Skip to content

fix(redis): honour _APP_REDIS_USER and pass credentials to the queue publisher - #13622

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/redis-acl-credentials
Sep 11, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/redis-acl-credentials

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What does this PR do?

Self-hosted installs with an external Redis that requires a user and password cannot log in. Three separate gaps, all reproduced against a Redis with requirepass plus an ACL user and the default user disabled:

The publisher half depends on utopia-php/queue actually calling auth(), which utopia-php/monorepo#260 adds. Until that is released and bumped here, cache, pubsub, lock and realtime authenticate correctly with this PR and the publisher still reports NOAUTH. The bump will be added to this PR once the tag exists.

Test Plan

Probe from inside the appwrite container against a Redis with requirepass secretpw and ACL SETUSER appwrite on >userpw ~* &* +@all, before this change:

OK    phpredis auth(pass) as default user            => true
FAIL  phpredis auth(pass) with ACL user password     => WRONGPASS invalid username-password pair or user is disabled.
OK    phpredis auth([user,pass]) ACL                 => true
FAIL  queue Connection\Redis host+port only          => NOAUTH Authentication required.
FAIL  queue Connection\Redis with user+pass          => NOAUTH Authentication required.
FAIL  DSN round-trip pass='p@ss:w/rd?x#y'            => Unable to parse DSN: redis://appwrite:p@ss:w/rd?x#y@redis-acl:6379

Then the stack (appwrite, appwrite-worker, appwrite-realtime, appwrite-task-scheduler) recreated with _APP_REDIS_HOST=redis-acl _APP_REDIS_USER=appwrite _APP_REDIS_PASS=userpw and the default user disabled, with this change applied:

  • Console account creation succeeds; no NOAUTH / WRONGPASS in the API or realtime logs.
  • CLIENT LIST on the Redis shows the API, cache, pubsub, lock and realtime connections as user=appwrite (hget, hset, get, evalsha, subscribe).
  • The publisher and consumer still fail, which is the library gap:
appwrite-task-scheduler   [StatsResources] Failed to publish stats resources message: NOAUTH Authentication required.
redis CLIENT LIST         15 × user=default cmd=brpop   (worker consumers, unauthenticated)

Unit: tests/unit/URL/URLTest.php passes. composer lint and PHPStan clean on the changed files.

Related PRs and Issues

Checklist

…publisher

Every Redis client authenticated with the password alone, so an ACL user configured through _APP_REDIS_USER was ignored and logins failed with WRONGPASS, and the queue publisher was built with host and port only, so a password-protected Redis rejected every publish with NOAUTH. Authenticate with the [user, password] pair when a user is set, hand the DSN credentials to the queue connection, and percent-encode credentials when building the fallback DSNs so passwords containing URL delimiters parse.
@greptile-apps

greptile-apps Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The reviewed changes appear safe to merge, with no new actionable defects or outstanding previous findings.

Summary

  • Authenticates Redis with username and password when an ACL username is configured.
  • Passes parsed credentials into the queue Redis connection.
  • Moves credential encoding to fallback DSN construction so URL::unparse() can safely reassemble already-encoded parsed URLs.
  • Uses explicit empty-string checks to support valid "0" usernames and passwords.

Reviews (2) · Last reviewed commit: "refactor(url): keep unparse() a plain re..."

Comment thread app/init/registers.php Resolved
Comment thread app/init/registers.php Resolved
Comment thread src/Appwrite/URL/URL.php Resolved
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/redis-acl-credentials (after).

Metric Before After Change
🚀 Requests/sec 184.64 184.93 ⚪ +0.2%
⏱️ Latency P50 93.33 ms 93.53 ms ⚪ +0.2%
⏱️ Latency P95 223.46 ms 224.8 ms ⚪ +0.6%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 93.53 224.8 11,571 184.93 +1.35
Account 189.77 338.04 609 10.08 -50.08
TablesDB 90.32 170.75 6,293 102.46 +3.01
Storage 85.72 184.83 3,045 51.5 -0.93
Functions 142.17 270.7 1,624 28.17 -0.13

Top API waits (after)

API request Max wait (ms)
account.prefs.update 546
account.name.update 511.01
functions.variables.create 499.86
storage.buckets.create 448.88
tablesdb.rows.delete 442.28

…user named 0

URL::unparse() also re-assembles parse_url() output in resolveLocation(), whose parts are already percent-encoded, so encoding inside unparse() double-encoded them. Encode the raw environment values where the fallback DSNs are built instead. Compare user and password against the empty string explicitly so a valid ACL username such as 0 is not dropped by PHP truthiness.
resolveLocation() feeds parse_url() parts back into unparse(), and those are already percent-encoded, so encoding inside unparse() double-encoded them. Credentials are encoded where the raw environment values enter the fallback DSNs instead.
@ChiragAgg5k
ChiragAgg5k merged commit 1b5d759 into main Sep 11, 2026
47 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/redis-acl-credentials branch September 11, 2026 09:57
pull Bot pushed a commit to AmirulAndalib/appwrite that referenced this pull request Sep 11, 2026
2.2.3 authenticates the queue Redis connection with the user and password Appwrite now passes from the DSN (appwrite#13622), so publishers and consumers work against a password-protected or ACL-secured Redis.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants