fix(queue): authenticate Redis connections when credentials are configured - #260
Merged
Conversation
…gured Connection\Redis accepted a user and password but never called auth(), so every publish and consume against a password-protected Redis failed with NOAUTH. Authenticate right after connect(), using the ACL [user, password] form when a user is set, and give RedisCluster the same optional credentials through phpredis's auth argument. Adds a requirepass + ACL compose node and an e2e test covering the default user, an ACL user, missing and wrong credentials.
ChiragAgg5k
requested review from
abnegate and
lohanidamodar
as code owners
September 11, 2026 09:21
2 tasks
loks0n
approved these changes
Sep 11, 2026
Contributor
|
Benchmark resultsqueue — workload shapes across both concurrency axes (4 cores, 600 messages, median of 3)
Shared CI runners — treat absolute numbers as rough, compare modes within a run. Commit 4e7a784. |
…er credentials Greptile flagged the NOAUTH/WRONGPASS message assertions as coupled to Redis protocol wording. A rejected push now has to throw and leave nothing on the server for a trusted connection to find, which holds across wording changes. RedisCluster gained credential parameters without a test that exercised them. A single-node cluster with requirepass and an ACL user is enough for phpredis to run the cluster handshake and authenticate, so the same four cases now run against it too.
Greptile flagged the NOAUTH/WRONGPASS message assertions as coupled to Redis protocol wording. A rejected push now has to throw and leave nothing on the server for a trusted connection to find, which holds across wording changes. Also drops the single-node authenticated cluster fixture added in the previous commit: cluster credentials are forwarded verbatim to phpredis and are not worth another compose service in this suite.
1 task
This was referenced Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Connection\Redishas accepted$userand$passwordin its constructor since 2.0, butgetRedis()only ever calledconnect(). Against a Redis withrequirepassor ACL users every publish and consume failed withNOAUTH Authentication required. Downstream this is appwrite/appwrite#13554: the Appwrite publisher pool and the worker consumer both go through this class, so a self-hosted install with an external, password-protected Redis cannot process any queue.Connection\Redis::getRedis()callsauth()right afterconnect()when a password is configured, using the ACL[user, password]pair when a user is set and the bare password otherwise. A rejected credential throwsRedisExceptioninside the existing connect retry loop, so a wrong password fails loudly with the host and port in the message instead of hanging.Connection\RedisClustergains optional$user/$passwordconstructor parameters and passes them as phpredis's\RedisCluster$authargument, so cluster mode can authenticate too. Existing call sites are unaffected.docker-compose.ymladds aredis-authnode on host port 16380 withrequirepass secretpwand an ACL userworker, and the e2e suite gainsRedisAuthTest.Supersedes #247, which covered
Connection\Redisonly and had no test.Test Plan
RedisAuthTestcovers the default user with a password, an ACL user, missing credentials, and a wrong password. With the fix:The same file against
mainwithsrc/stashed:Server-side confirmation that the connection is authenticated as the ACL user rather than
default. Afternew Connection\Redis('127.0.0.1', 16380, 'worker', 'workerpw')->rightPush(...),CLIENT LISTon theredis-authnode shows the pushing client as:tot-cmds=2isAUTHfollowed byRPUSH.End to end in Appwrite: with
_APP_REDIS_HOSTpointed at a Redis where thedefaultuser is disabled and only an ACL user exists, the API, cache, pubsub, lock and realtime pools authenticate (they receive an already-authenticated\Redis), while the queue publisher kept failing every hour with[StatsResources] Failed to publish stats resources message: NOAUTH Authentication required.and the worker'sBRPOPconnections showeduser=default. Those two are the paths this class owns. The Appwrite-side change that passes the DSN credentials into this constructor is ready and will bumputopia-php/queueonce this is tagged.bin/monorepo check queue --linked: Pint passes, Rector clean. PHPStan reports 5 errors (Nats::tick,Pool::maintain) that are identical onmainwithout this change.Related PRs and Issues