Merge pull request #303 from longelas/redis-custom-pass

Redis-custom-pass
This commit is contained in:
cytopia 2018-08-11 11:52:39 +02:00 committed by GitHub
commit d4deff1340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -402,6 +402,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

@ -576,6 +576,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
################################################################################