From a5786f3976b2cf20949d2239a3d415984e89a7df Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Thu, 26 Jan 2023 23:38:05 +0900 Subject: [PATCH] @uppy/companion: allow customizing express session prefix (#4249) * allow customizing express session prefix to make it easier to identify keys coming from companion the default value is just "sess:" which is a bit hard to identify * rename * document COMPANION_REDIS_EXPRESS_SESSION_PREFIX * change todo * Update companion.md * Update companion.md Co-authored-by: Merlijn Vos --- packages/@uppy/companion/src/standalone/index.js | 3 ++- website/src/docs/companion.md | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/companion/src/standalone/index.js b/packages/@uppy/companion/src/standalone/index.js index 649826d24..5336d759f 100644 --- a/packages/@uppy/companion/src/standalone/index.js +++ b/packages/@uppy/companion/src/standalone/index.js @@ -120,7 +120,8 @@ module.exports = function server (inputCompanionOptions = {}) { if (companionOptions.redisUrl) { const RedisStore = connectRedis(session) const redisClient = redis.client(companionOptions) - sessionOptions.store = new RedisStore({ client: redisClient }) + // todo next major: change default prefix to something like "companion:" and possibly remove this option + sessionOptions.store = new RedisStore({ client: redisClient, prefix: process.env.COMPANION_REDIS_EXPRESS_SESSION_PREFIX || 'sess:' }) } if (process.env.COMPANION_COOKIE_DOMAIN) { diff --git a/website/src/docs/companion.md b/website/src/docs/companion.md index 2b72c2bdc..6f1b43d76 100644 --- a/website/src/docs/companion.md +++ b/website/src/docs/companion.md @@ -296,6 +296,9 @@ export COMPANION_PERIODIC_PING_INTERVAL=60000 # corresponds to the periodicPingStaticPayload option (JSON string) export COMPANION_PERIODIC_PING_STATIC_JSON_PAYLOAD="{\"static\":\"data\"}" +# Set a custom prefix for redis keys created by [connect-redis](https://github.com/tj/connect-redis). Defaults to `sess:`. Sessions are used for storing authentication state and for allowing thumbnails to be loaded by the browser via Companion. You might want to change this because if you run a redis with many different apps in the same redis server, it's hard to know where `sess:` comes from and it might collide with other apps. **Note:** in the future ,we plan and changing the default to `companion:` and possibly remove this option. +export COMPANION_REDIS_EXPRESS_SESSION_PREFIX="sess:" + # If you need to use `companionKeysParams` (custom OAuth credentials at request time), # set this variable to a strong randomly generated secret. # See also https://github.com/transloadit/uppy/pull/2622