use secure default session secret
parent
174feea1b5
commit
b0d8d5c20d
|
@ -1,10 +1,13 @@
|
||||||
|
import crypto from 'crypto';
|
||||||
import { auth, ConfigParams } from 'express-openid-connect';
|
import { auth, ConfigParams } from 'express-openid-connect';
|
||||||
import ChatServer from './index';
|
import ChatServer from './index';
|
||||||
|
|
||||||
|
const secret = process.env.AUTH_SECRET || crypto.randomBytes(32).toString('hex');
|
||||||
|
|
||||||
const config: ConfigParams = {
|
const config: ConfigParams = {
|
||||||
authRequired: false,
|
authRequired: false,
|
||||||
auth0Logout: false,
|
auth0Logout: false,
|
||||||
secret: process.env.AUTH_SECRET || 'keyboard cat',
|
secret,
|
||||||
baseURL: process.env.PUBLIC_URL,
|
baseURL: process.env.PUBLIC_URL,
|
||||||
clientID: process.env.AUTH0_CLIENT_ID,
|
clientID: process.env.AUTH0_CLIENT_ID,
|
||||||
issuerBaseURL: process.env.AUTH0_ISSUER,
|
issuerBaseURL: process.env.AUTH0_ISSUER,
|
||||||
|
|
|
@ -5,6 +5,8 @@ import createSQLiteSessionStore from 'connect-sqlite3';
|
||||||
import { Strategy as LocalStrategy } from 'passport-local';
|
import { Strategy as LocalStrategy } from 'passport-local';
|
||||||
import ChatServer from './index';
|
import ChatServer from './index';
|
||||||
|
|
||||||
|
const secret = process.env.AUTH_SECRET || crypto.randomBytes(32).toString('hex');
|
||||||
|
|
||||||
export function configurePassport(context: ChatServer) {
|
export function configurePassport(context: ChatServer) {
|
||||||
const SQLiteStore = createSQLiteSessionStore(session);
|
const SQLiteStore = createSQLiteSessionStore(session);
|
||||||
const sessionStore = new SQLiteStore({ db: 'sessions.db' });
|
const sessionStore = new SQLiteStore({ db: 'sessions.db' });
|
||||||
|
@ -42,7 +44,7 @@ export function configurePassport(context: ChatServer) {
|
||||||
});
|
});
|
||||||
|
|
||||||
context.app.use(session({
|
context.app.use(session({
|
||||||
secret: process.env.AUTH_SECRET || 'keyboard cat',
|
secret,
|
||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: false,
|
saveUninitialized: false,
|
||||||
store: sessionStore as any,
|
store: sessionStore as any,
|
||||||
|
|
Loading…
Reference in New Issue