-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[redis] Authentication support added #350
Conversation
if (array_key_exists('auth', $this->config)) { | ||
$this->redis->auth($this->config['auth']); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure we need the first if if (array_key_exists('pass', $this->config)) {
.
<?php
if (array_key_exists('pass', $this->config)) {
$this->redis->auth($this->config['pass']);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for services like Heroku.
They provide a token for authentication in the password part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code I posted does exactly the same but with one if
statement.
This will be possible once #372 is merged. Like this: <?php
use Enqueue\Redis\RedisConnectionFactory;
use Enqueue\Redis\PRedis;
$config = [];
$options = [];
$predis = new \PRedis\Client($config, $options);
$predis->auth('aPassword');
$redis = new PRedis();
$factory = new RedisConnectionFactory(['vendor' => 'custom', 'redis' => $redis]); |
@makasim Does it mean, that authentication will only be supported by the PRedis client? |
Yes, the Enqueue\PhpRedis constructor has to be adjusted to accept the instance of |
Please reconsider your decision. It would be very useful to consume the authentication from within the DSN. Creating an own instance of a redis client only to support authentication is much more overhead and not necessary. |
I completely agree, when using various large hosters an authorization to the redis Instance is required. Only for this purpose a pre-configured redis instance must be explicitly created instead of drawing the maximum benefit from the existing functionalities, especially since the adaptation effort is apparently very low and non-invasive. |
I agree too, it's not so uncommon to use redis with password, it's not really practical to create an custom vendor. It's more easy with DSN, other transporters handle password mechanism in DSN |
I don't mind adding authentication option if it is widely used and many want to see it supported. |
@makasim I'm glad to hear this and I would be appreciated if you wold merge my changes. |
Can you add auth support to predis too? |
and some tests. |
add auth option to the doc block https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/redis/RedisConnectionFactory.php#L31 |
merged as part of #497. both ways are supported you can pass |
Use the authentication information provided by the config after parsing a dsn.
Closes #349