Redis-custom-pass

This commit is contained in:
Horváth Máté 2018-07-05 23:50:24 +02:00
parent 3ee0649275
commit 47b3491f3a
4 changed files with 21 additions and 1 deletions

View File

@ -128,7 +128,13 @@ function loadClass($class) {
case 'Redis':
loadFile($class, $cnt_dir);
$_LOADED_LIBS[$class] = \devilbox\Redis::getInstance($GLOBALS['REDIS_HOST_NAME']);
if(loadClass('Helper')->getEnv('REDIS_ROOT_PASSWORD') == ''){
$_LOADED_LIBS[$class] = \devilbox\Redis::getInstance($GLOBALS['REDIS_HOST_NAME']);
}else{
$_LOADED_LIBS[$class] = \devilbox\Redis::getInstance($GLOBALS['REDIS_HOST_NAME'], array(
'pass' => loadClass('Helper')->getEnv('REDIS_ROOT_PASSWORD'),
));
}
break;
case 'Memcd':

View File

@ -44,6 +44,9 @@ class Redis extends BaseClass implements BaseInterface
$this->setConnectErrno(1);
//loadClass('Logger')->error($this->_connect_error);
} else {
if(array_key_exists('pass', $data)){
$redis->auth($data['pass']);
}
$redis->set('devilbox-version', $GLOBALS['DEVILBOX_VERSION'].' ('.$GLOBALS['DEVILBOX_DATE'].')');
$this->_redis = $redis;
}

View File

@ -394,6 +394,12 @@ services:
# ------------------------------------------------------------
redis:
image: redis:${REDIS_SERVER:-3.2}
# REDIS CUSTOM PASSWORD SETUP
#comment out the following 3 lines if you want to set a custom redis password, also set the redis pass variable in .env
#command: redis-server --requirepass ${REDIS_ROOT_PASSWORD}
#environment:
# - ALLOW_EMPTY_PASSWORD=yes
ports:
# [local-machine:]local-port:docker-port

View File

@ -541,6 +541,11 @@ HOST_PORT_PGSQL=5432
###
HOST_PORT_REDIS=6379
###
### Comment out to set the redis custom password also, in docker-compose.yml comment out the REDIS CUSTOM PASSWORD SETUP section
###
#REDIS_ROOT_PASSWORD=root
################################################################################