@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 <merlijn@soverin.net>
This commit is contained in:
Mikael Finstad 2023-01-26 23:38:05 +09:00 committed by GitHub
parent 6d5f67849f
commit a5786f3976
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -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) {

View file

@ -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