Skip to content

Commit

Permalink
@uppy/companion: allow customizing express session prefix (#4249)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
mifi and Murderlon authored Jan 26, 2023
1 parent 6d5f678 commit a5786f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/@uppy/companion/src/standalone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions website/src/docs/companion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a5786f3

Please sign in to comment.