Add 'username' auth option to Redis driver #413
Merged
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.
This PR implements an additional option
username
to be used with Redis clusters that have ACL rules (Redis 6+) with non-default users.I have changed the
auth
method parameters to use associative arrays, because I thought it would be less confusing to someone reading the code. More info on parameter styles here.How I tested it:
Start a Redis container without authentication enabled.
username
orpassword
.password
option.Fatal error: Uncaught RedisException: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? in /usr/src/src/Stash/Driver/Redis.php:137
(followed by a stack trace).username
andpassword
.Fatal error: Uncaught RedisException: WRONGPASS invalid username-password pair or user is disabled. in /usr/src/src/Stash/Driver/Redis.php:133
(followed by a stack trace).Start a Redis container and change the authentication password for the default user.
ACL SETUSER default >somepassword
username
orpassword
.Caught exception: NOAUTH Authentication required.
(I used atry-catch
block of code).password
option.username
andpassword
.Fatal error: Uncaught RedisException: WRONGPASS invalid username-password pair or user is disabled. in /usr/src/src/Stash/Driver/Redis.php:133
(followed by a stack trace).Start a Redis container and create a new user, disabling the
default
user.ACL SETUSER default off
ACL SETUSER someuser on allkeys allcommands allchannels >somepasshere
username
orpassword
.Caught exception: NOAUTH Authentication required.
(I used atry-catch
block of code).password
option.Fatal error: Uncaught RedisException: ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? in /usr/src/src/Stash/Driver/Redis.php:137
(followed by a stack trace).username
andpassword
options.Closes #412