-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Redis as session store (#4)
* Added support for Redis as session store (via env variable SESSION_STORE_TYPE). Fixes Haufe-Lexware/wicked.haufe.io#83 * Added connect-redis to package.json. See Haufe-Lexware/wicked.haufe.io#83 * Redis sessions - read configuration from globals instead of directly from env vars. * Better support for feature branch building.
- Loading branch information
1 parent
b99728d
commit 799959d
Showing
6 changed files
with
77 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
FROM ${DOCKER_PREFIX}portal-env:${DOCKER_TAG}-onbuild${BUILD_ALPINE} | ||
FROM ${DOCKER_PREFIX}portal-env:${DOCKER_ENV_TAG}${BUILD_ALPINE} | ||
|
||
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var debug = require('debug')('portal:sessionstore'); | ||
|
||
function initSessionStore(globals, session){ | ||
let sessionStoreType = 'file'; | ||
if (globals.sessionStore && globals.sessionStore.type) { | ||
sessionStoreType = globals.sessionStore.type; | ||
} else { | ||
console.error('WARNING: Missing sessionStore global property, defaulting to file session store - THIS WILL NOT SCALE.'); | ||
globals.sessionStore = { type: 'file' }; | ||
} | ||
debug('SESSION_STORE_TYPE: ' + sessionStoreType); | ||
|
||
var sessionStoreOptions = {}; | ||
var SessionStore; | ||
switch (sessionStoreType){ | ||
case 'file': | ||
SessionStore = require('session-file-store')(session); | ||
// Use default options for file session store, see https://www.npmjs.com/package/session-file-store | ||
break; | ||
case 'redis': | ||
SessionStore = require('connect-redis')(session); | ||
// Set options for Redis session store, see https://www.npmjs.com/package/connect-redis | ||
sessionStoreOptions.host = globals.sessionStore.host || 'portal-redis'; | ||
sessionStoreOptions.port = globals.sessionStore.port || 6379; | ||
if (globals.sessionStore.password) | ||
sessionStoreOptions.pass = globals.sessionStore.password; | ||
break; | ||
default: | ||
throw new Error("Invalid session-store type: '" + sessionStoreType + "'"); | ||
} | ||
|
||
debug('Using session store \'' + sessionStoreType + '\' with options ' + JSON.stringify(sessionStoreOptions)); | ||
|
||
return new SessionStore(sessionStoreOptions); | ||
} | ||
|
||
module.exports = initSessionStore; |