fix(ios): send the Redis ACL username so Valkey and Redis 6 users can sign in - #2084
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
A user reported that a Valkey login works in TablePro on macOS but is rejected on iOS and in the mobile app running on a Mac. Their password is 64 hex characters from
openssl rand -hex 32, which is a red herring: that is exactly what Redis's ownACL GENPASSproduces, and hiredis sends it with an explicit byte length.Root cause
The mobile driver never sends the ACL username.
Redis and Valkey hard-code the one-argument form of
AUTHto thedefaultuser. FromauthCommand()insrc/acl.c, identical in every Redis 6+ and every Valkey:So
AUTH <password>checks the password againstdefault, never against an ACL user, and answersWRONGPASS invalid username-password pair or user is disabled.The two code paths had diverged:
RedisPluginConnection.swiftsent["AUTH", username, password]when a username was set. Works.RedisDriver.swiftalways sent["AUTH", password]and had nousernameproperty, andIOSDriverFactoryforwardedconnection.usernameto MySQL and PostgreSQL but not to Redis.The iOS form has always shown a Username field for Redis, and it saved and synced. The user filled it in, the app stored it, and the driver threw it away.
docs/databases/redis.mdxalready documented the field as "sent asAUTH username password".What changed
Rather than adding a username parameter and leaving two hand-written copies of the same logic, the AUTH rules and the Redis database-index resolution moved into two pure files that both platforms call:
RedisAuthCommanddecides the AUTH argument shape and classifies the server's rejection.RedisDatabaseIndexresolvesadditionalFields["redisDatabase"]thendatabasethen0.Also fixed on mobile, found on the same path:
db=ACL selectors scope a user to specific databases, and connections always start in db 0.Error messages
A rejected login now says what to change. When no username was sent, it points at the Username field. Redis's
nopassreply and a pre-6 server's arity error each get their own message.WRONGPASSwith a username supplied gets no hint, because the server deliberately does not say which half was wrong.ERR invalid passwordis a Redis 5 reply and maps to a plain rejection with no hint, since Redis 5 has no ACL users and suggesting a username there would be wrong.Testing
13 new unit tests over the two pure helpers, plus 2 for the SSL accessors. macOS
RedisDriverplugin builds, iOS app builds,swiftlint --strictclean.Note
docs/databases/redis.mdxalso documents a related trap:>passwordsets a password and#hashsets a SHA-256 hash, and a 64-character hex string is syntactically valid for both.ACL SETUSER u on #<64-hex>is accepted where>was meant and fails every later login with the sameWRONGPASS.