forked from acouzens/open5gs
move session information to sqlite db
This commit is contained in:
parent
2b0526bf56
commit
db473e8ed6
|
@ -0,0 +1,15 @@
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Session = sequelize.define('Session', {
|
||||||
|
sid: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
primaryKey: true,
|
||||||
|
},
|
||||||
|
userId: DataTypes.STRING,
|
||||||
|
expires: DataTypes.DATE,
|
||||||
|
data: DataTypes.STRING(50000)
|
||||||
|
}, {
|
||||||
|
freezeTableName: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return Session;
|
||||||
|
};
|
|
@ -8,6 +8,7 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.17.1",
|
"body-parser": "^1.17.1",
|
||||||
|
"connect-session-sequelize": "^4.1.0",
|
||||||
"express": "^4.15.2",
|
"express": "^4.15.2",
|
||||||
"express-session": "^1.15.2",
|
"express-session": "^1.15.2",
|
||||||
"lusca": "^1.4.1",
|
"lusca": "^1.4.1",
|
||||||
|
@ -17,7 +18,6 @@
|
||||||
"react": "^15.5.4",
|
"react": "^15.5.4",
|
||||||
"react-dom": "^15.5.4",
|
"react-dom": "^15.5.4",
|
||||||
"sequelize": "^3.30.4",
|
"sequelize": "^3.30.4",
|
||||||
"session-file-store": "^1.0.0",
|
|
||||||
"sqlite3": "^3.1.8"
|
"sqlite3": "^3.1.8"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const session = require('express-session');
|
const session = require('express-session');
|
||||||
const csrf = require('lusca').csrf();
|
const csrf = require('lusca').csrf();
|
||||||
const FileStore = require('session-file-store')(session);
|
const SequelizeStore = require('connect-session-sequelize')(session.Store);
|
||||||
const passport = require('passport');
|
const passport = require('passport');
|
||||||
const LocalStrategy = require('passport-local').Strategy;
|
const LocalStrategy = require('passport-local').Strategy;
|
||||||
|
const models = require('../models');
|
||||||
|
|
||||||
exports.configure = ({
|
exports.configure = ({
|
||||||
app = null,
|
app = null,
|
||||||
server = null,
|
server = null,
|
||||||
models = null,
|
|
||||||
secret = 'change-me',
|
secret = 'change-me',
|
||||||
store = new FileStore({ path: '/tmp/sessions', secret: secret }),
|
store = new SequelizeStore({ db: models.sequelize, table: 'Session' }),
|
||||||
maxAge = 60000 * 60 * 24 * 7 * 4, // 4 weeks
|
maxAge = 60000 * 60 * 24 * 7 * 4, // 4 weeks
|
||||||
clientMaxAge = 60 * 1000 // 60 seconds
|
clientMaxAge = 60 * 1000 // 60 seconds
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
if (!app) throw new Error('Null param')
|
if (!app) throw new Error('Null param')
|
||||||
if (!server) throw new Error('Null param')
|
if (!server) throw new Error('Null param')
|
||||||
if (!models) throw new Error('Null param')
|
|
||||||
|
|
||||||
models.UserRole.count().then(c => {
|
models.UserRole.count().then(c => {
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ app.prepare()
|
||||||
auth.configure({
|
auth.configure({
|
||||||
app: app,
|
app: app,
|
||||||
server: server,
|
server: server,
|
||||||
models: models,
|
|
||||||
secret: process.env.SESSION_SECRET
|
secret: process.env.SESSION_SECRET
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -795,10 +795,6 @@ babylon@^6.11.0, babylon@^6.15.0:
|
||||||
version "6.17.1"
|
version "6.17.1"
|
||||||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f"
|
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f"
|
||||||
|
|
||||||
bagpipe@^0.3.5:
|
|
||||||
version "0.3.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/bagpipe/-/bagpipe-0.3.5.tgz#e341d164fcb24cdf04ea7e05b765ec10c8aea6a1"
|
|
||||||
|
|
||||||
balanced-match@^0.4.1:
|
balanced-match@^0.4.1:
|
||||||
version "0.4.2"
|
version "0.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
|
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
|
||||||
|
@ -1057,6 +1053,13 @@ concat-map@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||||
|
|
||||||
|
connect-session-sequelize@^4.1.0:
|
||||||
|
version "4.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/connect-session-sequelize/-/connect-session-sequelize-4.1.0.tgz#d402749c3bebd79209192c164c090742b3fe2011"
|
||||||
|
dependencies:
|
||||||
|
debug "^2.1.1"
|
||||||
|
deep-equal "^1.0.1"
|
||||||
|
|
||||||
console-browserify@^1.1.0:
|
console-browserify@^1.1.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
|
resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
|
||||||
|
@ -1184,7 +1187,7 @@ date-now@^0.1.4:
|
||||||
version "0.1.4"
|
version "0.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
|
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
|
||||||
|
|
||||||
debug@2.6.1:
|
debug@2.6.1, debug@^2.1.1:
|
||||||
version "2.6.1"
|
version "2.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1196,7 +1199,7 @@ debug@2.6.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
ms "0.7.2"
|
ms "0.7.2"
|
||||||
|
|
||||||
debug@2.6.4, debug@^2.1.1, debug@^2.2.0:
|
debug@2.6.4, debug@^2.2.0:
|
||||||
version "2.6.4"
|
version "2.6.4"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1206,6 +1209,10 @@ decamelize@^1.0.0, decamelize@^1.1.1:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||||
|
|
||||||
|
deep-equal@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
|
||||||
|
|
||||||
deep-extend@~0.4.0:
|
deep-extend@~0.4.0:
|
||||||
version "0.4.2"
|
version "0.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
|
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
|
||||||
|
@ -1579,14 +1586,6 @@ friendly-errors-webpack-plugin@1.5.0:
|
||||||
error-stack-parser "^2.0.0"
|
error-stack-parser "^2.0.0"
|
||||||
string-length "^1.0.1"
|
string-length "^1.0.1"
|
||||||
|
|
||||||
fs-extra@^1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950"
|
|
||||||
dependencies:
|
|
||||||
graceful-fs "^4.1.2"
|
|
||||||
jsonfile "^2.1.0"
|
|
||||||
klaw "^1.0.0"
|
|
||||||
|
|
||||||
fs.realpath@^1.0.0:
|
fs.realpath@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||||
|
@ -1706,7 +1705,7 @@ globby@^5.0.0:
|
||||||
pify "^2.0.0"
|
pify "^2.0.0"
|
||||||
pinkie-promise "^2.0.0"
|
pinkie-promise "^2.0.0"
|
||||||
|
|
||||||
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
|
graceful-fs@^4.1.2:
|
||||||
version "4.1.11"
|
version "4.1.11"
|
||||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
|
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
|
||||||
|
|
||||||
|
@ -1833,10 +1832,6 @@ ieee754@^1.1.4:
|
||||||
version "1.1.8"
|
version "1.1.8"
|
||||||
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
|
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
|
||||||
|
|
||||||
imurmurhash@^0.1.4:
|
|
||||||
version "0.1.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
|
|
||||||
|
|
||||||
indexof@0.0.1:
|
indexof@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d"
|
resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d"
|
||||||
|
@ -2079,12 +2074,6 @@ json5@^0.5.0, json5@^0.5.1:
|
||||||
version "0.5.1"
|
version "0.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
||||||
|
|
||||||
jsonfile@^2.1.0:
|
|
||||||
version "2.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
|
|
||||||
optionalDependencies:
|
|
||||||
graceful-fs "^4.1.6"
|
|
||||||
|
|
||||||
jsonify@~0.0.0:
|
jsonify@~0.0.0:
|
||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
|
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
|
||||||
|
@ -2104,12 +2093,6 @@ kind-of@^3.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
is-buffer "^1.1.5"
|
is-buffer "^1.1.5"
|
||||||
|
|
||||||
klaw@^1.0.0:
|
|
||||||
version "1.3.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439"
|
|
||||||
optionalDependencies:
|
|
||||||
graceful-fs "^4.1.9"
|
|
||||||
|
|
||||||
lazy-cache@^1.0.3:
|
lazy-cache@^1.0.3:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
|
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
|
||||||
|
@ -3019,10 +3002,6 @@ retry-as-promised@^2.0.0:
|
||||||
cross-env "^3.1.2"
|
cross-env "^3.1.2"
|
||||||
debug "^2.2.0"
|
debug "^2.2.0"
|
||||||
|
|
||||||
retry@^0.10.0:
|
|
||||||
version "0.10.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4"
|
|
||||||
|
|
||||||
right-align@^0.1.1:
|
right-align@^0.1.1:
|
||||||
version "0.1.3"
|
version "0.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
|
resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
|
||||||
|
@ -3122,15 +3101,6 @@ serve-static@1.12.1:
|
||||||
parseurl "~1.3.1"
|
parseurl "~1.3.1"
|
||||||
send "0.15.1"
|
send "0.15.1"
|
||||||
|
|
||||||
session-file-store@^1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/session-file-store/-/session-file-store-1.0.0.tgz#17d6a1f4b548c4ce8a5b808d268637abeb46dcf4"
|
|
||||||
dependencies:
|
|
||||||
bagpipe "^0.3.5"
|
|
||||||
fs-extra "^1.0.0"
|
|
||||||
retry "^0.10.0"
|
|
||||||
write-file-atomic "^1.1.4"
|
|
||||||
|
|
||||||
set-blocking@^2.0.0, set-blocking@~2.0.0:
|
set-blocking@^2.0.0, set-blocking@~2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
|
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
|
||||||
|
@ -3175,10 +3145,6 @@ slash@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
||||||
|
|
||||||
slide@^1.1.5:
|
|
||||||
version "1.1.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707"
|
|
||||||
|
|
||||||
sntp@1.x.x:
|
sntp@1.x.x:
|
||||||
version "1.0.9"
|
version "1.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"
|
resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"
|
||||||
|
@ -3634,14 +3600,6 @@ wrappy@1:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||||
|
|
||||||
write-file-atomic@^1.1.4:
|
|
||||||
version "1.3.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f"
|
|
||||||
dependencies:
|
|
||||||
graceful-fs "^4.1.11"
|
|
||||||
imurmurhash "^0.1.4"
|
|
||||||
slide "^1.1.5"
|
|
||||||
|
|
||||||
write-file-webpack-plugin@4.0.2:
|
write-file-webpack-plugin@4.0.2:
|
||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/write-file-webpack-plugin/-/write-file-webpack-plugin-4.0.2.tgz#70c89a4d99a105e1aed778b21b5f75e7af4da58b"
|
resolved "https://registry.yarnpkg.com/write-file-webpack-plugin/-/write-file-webpack-plugin-4.0.2.tgz#70c89a4d99a105e1aed778b21b5f75e7af4da58b"
|
||||||
|
|
Loading…
Reference in New Issue