Add support for connecting to redis with an ssl file and password. #206
This commit is contained in:
parent
afc07e7c68
commit
a166a5f09a
2 changed files with 26 additions and 5 deletions
|
|
@ -80,6 +80,9 @@ services:
|
|||
$scheme: "%env(REDIS_CLIENT_SCHEME)%"
|
||||
$host: "%env(REDIS_CLIENT_HOST)%"
|
||||
$port: "%env(REDIS_CLIENT_PORT)%"
|
||||
$cert_file: "%env(REDIS_CLIENT_CERTFILE)%"
|
||||
$password: "%env(REDIS_CLIENT_PASSWORD)%"
|
||||
$env_flag: "dev"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyUserProvider:
|
||||
arguments:
|
||||
|
|
|
|||
|
|
@ -10,20 +10,38 @@ class RedisClient
|
|||
protected $scheme;
|
||||
protected $host;
|
||||
protected $port;
|
||||
protected $cert_file;
|
||||
protected $password;
|
||||
protected $env_flag;
|
||||
|
||||
public function __construct($scheme, $host, $port)
|
||||
public function __construct($scheme, $host, $port, $cert_file, $password, $env_flag)
|
||||
{
|
||||
$this->scheme = $scheme;
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
$this->cert_file = $cert_file;
|
||||
$this->password = $password;
|
||||
$this->env_flag = $env_flag;
|
||||
}
|
||||
|
||||
public function getRedisClient()
|
||||
{
|
||||
$this->redis = new PredisClient([
|
||||
"scheme"=>$this->scheme,
|
||||
"host"=>$this->host,
|
||||
"port"=>$this->port]);
|
||||
if ($this->env_flag == 'dev')
|
||||
{
|
||||
$this->redis = new PredisClient([
|
||||
"scheme"=>$this->scheme,
|
||||
"host"=>$this->host,
|
||||
"port"=>$this->port]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->redis = new PredisClient([
|
||||
"scheme"=>$this->scheme,
|
||||
"host"=>$this->host,
|
||||
"port"=>$this->port,
|
||||
"ssl"=>["cafile"=>$cert_file, "verify_peer"=>true],
|
||||
"password"=>$password]);
|
||||
}
|
||||
return $this->redis;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue