|
|
@ -4,15 +4,13 @@ import expressSession, { |
|
|
|
Store as BaseSessionStore, |
|
|
|
Store as BaseSessionStore, |
|
|
|
} from 'express-session'; |
|
|
|
} from 'express-session'; |
|
|
|
|
|
|
|
|
|
|
|
import { DELETED } from '../lib/consts'; |
|
|
|
import { COOKIE_ORIGINAL_MAX_AGE, DELETED } from '../lib/consts'; |
|
|
|
|
|
|
|
|
|
|
|
import { getLocalHostUUID, query, timestamp, write } from '../lib/accessModule'; |
|
|
|
import { getLocalHostUUID, query, timestamp, write } from '../lib/accessModule'; |
|
|
|
import { cname } from '../lib/cname'; |
|
|
|
import { cname } from '../lib/cname'; |
|
|
|
import { getSessionSecret } from '../lib/getSessionSecret'; |
|
|
|
import { getSessionSecret } from '../lib/getSessionSecret'; |
|
|
|
import { stderr, stdout, stdoutVar, uuid } from '../lib/shell'; |
|
|
|
import { stderr, stdout, stdoutVar, uuid } from '../lib/shell'; |
|
|
|
|
|
|
|
|
|
|
|
const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 28800000; // 8 hours
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class SessionStore extends BaseSessionStore { |
|
|
|
export class SessionStore extends BaseSessionStore { |
|
|
|
constructor(options = {}) { |
|
|
|
constructor(options = {}) { |
|
|
|
super(options); |
|
|
|
super(options); |
|
|
@ -85,7 +83,7 @@ export class SessionStore extends BaseSessionStore { |
|
|
|
const data: SessionData = { |
|
|
|
const data: SessionData = { |
|
|
|
cookie: { |
|
|
|
cookie: { |
|
|
|
maxAge: cookieMaxAge, |
|
|
|
maxAge: cookieMaxAge, |
|
|
|
originalMaxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
originalMaxAge: COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
}, |
|
|
|
}, |
|
|
|
passport: { user: userUuid }, |
|
|
|
passport: { user: userUuid }, |
|
|
|
}; |
|
|
|
}; |
|
|
@ -169,7 +167,7 @@ export class SessionStore extends BaseSessionStore { |
|
|
|
|
|
|
|
|
|
|
|
public static calculateCookieMaxAge( |
|
|
|
public static calculateCookieMaxAge( |
|
|
|
sessionModifiedDate: string, |
|
|
|
sessionModifiedDate: string, |
|
|
|
cookieOriginalMaxAge: number = DEFAULT_COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
cookieOriginalMaxAge: number = COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
) { |
|
|
|
) { |
|
|
|
const sessionModifiedEpoch = Date.parse(sessionModifiedDate); |
|
|
|
const sessionModifiedEpoch = Date.parse(sessionModifiedDate); |
|
|
|
const sessionDeadlineEpoch = sessionModifiedEpoch + cookieOriginalMaxAge; |
|
|
|
const sessionDeadlineEpoch = sessionModifiedEpoch + cookieOriginalMaxAge; |
|
|
@ -185,7 +183,7 @@ export default (async () => |
|
|
|
expressSession({ |
|
|
|
expressSession({ |
|
|
|
cookie: { |
|
|
|
cookie: { |
|
|
|
httpOnly: true, |
|
|
|
httpOnly: true, |
|
|
|
maxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
maxAge: COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
secure: false, |
|
|
|
secure: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
genid: ({ originalUrl }) => { |
|
|
|
genid: ({ originalUrl }) => { |
|
|
|