Browse Source
Merge pull request #2581 from Budibase/fix/enable-redis-ssl
Fix/enable redis ssl
gh-pages
Martin McKeaveney
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
14 additions and
2 deletions
-
packages/auth/src/redis/index.js
-
packages/auth/src/redis/utils.js
|
|
@ -56,9 +56,13 @@ function init() { |
|
|
if (CLIENT) { |
|
|
if (CLIENT) { |
|
|
CLIENT.disconnect() |
|
|
CLIENT.disconnect() |
|
|
} |
|
|
} |
|
|
const { opts, host, port } = getRedisOptions(CLUSTERED) |
|
|
|
|
|
|
|
|
const { redisProtocolUrl, opts, host, port } = getRedisOptions(CLUSTERED) |
|
|
|
|
|
|
|
|
if (CLUSTERED) { |
|
|
if (CLUSTERED) { |
|
|
CLIENT = new Redis.Cluster([{ host, port }], opts) |
|
|
CLIENT = new Redis.Cluster([{ host, port }], opts) |
|
|
|
|
|
} else if (redisProtocolUrl) { |
|
|
|
|
|
CLIENT = new Redis(redisProtocolUrl) |
|
|
} else { |
|
|
} else { |
|
|
CLIENT = new Redis(opts) |
|
|
CLIENT = new Redis(opts) |
|
|
} |
|
|
} |
|
|
|
|
|
@ -19,6 +19,14 @@ exports.SEPARATOR = SEPARATOR |
|
|
|
|
|
|
|
|
exports.getRedisOptions = (clustered = false) => { |
|
|
exports.getRedisOptions = (clustered = false) => { |
|
|
const [host, port] = REDIS_URL.split(":") |
|
|
const [host, port] = REDIS_URL.split(":") |
|
|
|
|
|
|
|
|
|
|
|
let redisProtocolUrl |
|
|
|
|
|
|
|
|
|
|
|
// fully qualified redis URL
|
|
|
|
|
|
if (/rediss?/.test(host)) { |
|
|
|
|
|
redisProtocolUrl = REDIS_URL |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const opts = { |
|
|
const opts = { |
|
|
connectTimeout: CONNECT_TIMEOUT_MS, |
|
|
connectTimeout: CONNECT_TIMEOUT_MS, |
|
|
} |
|
|
} |
|
|
@ -33,7 +41,7 @@ exports.getRedisOptions = (clustered = false) => { |
|
|
opts.port = port |
|
|
opts.port = port |
|
|
opts.password = REDIS_PASSWORD |
|
|
opts.password = REDIS_PASSWORD |
|
|
} |
|
|
} |
|
|
return { opts, host, port } |
|
|
return { opts, host, port, redisProtocolUrl } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.addDbPrefix = (db, key) => { |
|
|
exports.addDbPrefix = (db, key) => { |
|
|
|