Skip to content

Redis client can now connect with TLS and >=6.0 ACL AUTH settings. #35

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
"redis": {
"host": "localhost",
"port": 6379,
"database": "0",
"username": "default",
"password": null,
"ca-file": null,
"keyPrefix": "ru102js"
}
}
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
},
"private": true,
"scripts": {
"dev": "./node_modules/nodemon/bin/nodemon.js",
"load": "node src/utils/data_loader.js --",
"dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ./node_modules/nodemon/bin/nodemon.js",
"load": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/utils/data_loader.js --",
"lint": "./node_modules/eslint/bin/eslint.js src tests",
"start": "node ./src/app.js",
"test": "jest --no-colors",
"testdev": "jest --watch"
"start": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./src/app.js",
"test": "NODE_TLS_REJECT_UNAUTHORIZED=0 jest --no-colors",
"testdev": "NODE_TLS_REJECT_UNAUTHORIZED=0 jest --watch"
},
"author": "Redis",
"engines": {
Expand All @@ -29,7 +29,7 @@
"express-validator": "^6.0.0",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"redis": "^2.8.0",
"redis": "2.8.0",
"round-to": "^4.0.0",
"shortid": "^2.2.14",
"winston": "^3.2.1"
Expand Down
18 changes: 17 additions & 1 deletion src/daos/impl/redis/redis_client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const redis = require('redis');
const bluebird = require('bluebird');
const config = require('better-config');
const fs = require('fs');

// Add extra definitions for RedisTimeSeries commands.
redis.addCommand('ts.add'); // redis.ts_addAsync
Expand All @@ -13,13 +14,28 @@ bluebird.promisifyAll(redis);
// from config.json.
const clientConfig = {
host: config.get('dataStores.redis.host'),
port: config.get('dataStores.redis.port'),
port: config.get('dataStores.redis.port')
};

if (config.get('dataStores.redis.database')) {
database: parseInt(config.get('dataStores.redis.database'))
}

if (config.get('dataStores.redis.password')) {
clientConfig.password = config.get('dataStores.redis.password');
}

if (config.get('dataStores.redis.username')) {
clientConfig.username = config.get('dataStores.redis.username');
}

if (config.get('dataStores.redis.ca-file')) {
clientConfig.tls = {};
clientConfig.tls.ca = [ fs.readFileSync(config.get('dataStores.redis.ca-file')) ];
clientConfig.tls.rejectUnauthorized = false;
clientConfig.tls.requestCert = true;
}

const client = redis.createClient(clientConfig);

// This is a catch all basic error handler.
Expand Down