rolling session
This commit is contained in:
parent
68512ec871
commit
16016071a4
@ -17,7 +17,7 @@ import { MiddlewareFunction, Request, Response } from "../../../@types/Server.js
|
||||
import { NextFunction } from "express";
|
||||
import { User } from "../structures/index.js";
|
||||
|
||||
const OAuthLinks: {[key: string]: string} = {};
|
||||
const OAuthLinks: { [key: string]: string } = {};
|
||||
|
||||
type Cookie = {
|
||||
secure?: boolean,
|
||||
@ -45,7 +45,7 @@ class Authenticator {
|
||||
|
||||
#passport: passport.Authenticator;
|
||||
#logger: LoggerClient;
|
||||
#OAuthParams: {[key: string]: OAuthParams | null};
|
||||
#OAuthParams: { [key: string]: OAuthParams | null };
|
||||
|
||||
/**
|
||||
* Creates an instance of Authenticator.
|
||||
@ -64,7 +64,19 @@ class Authenticator {
|
||||
constructor (
|
||||
server: Server,
|
||||
users: UserDatabaseInterface,
|
||||
{ sessionStorage, secret, name, cookie = {} }: { sessionStorage: MongoStore, secret: string, name: string, cookie: Cookie }
|
||||
{
|
||||
rollingSession = true,
|
||||
sessionStorage,
|
||||
secret,
|
||||
name,
|
||||
cookie = {}
|
||||
}: {
|
||||
sessionStorage: MongoStore,
|
||||
rollingSession?: boolean,
|
||||
secret: string,
|
||||
name: string,
|
||||
cookie: Cookie
|
||||
}
|
||||
) {
|
||||
|
||||
// if (!(users instanceof UserDatabaseInterface))
|
||||
@ -85,7 +97,8 @@ class Authenticator {
|
||||
store: sessionStorage,
|
||||
secret,
|
||||
resave: false,
|
||||
saveUninitialized: false
|
||||
saveUninitialized: false,
|
||||
rolling: rollingSession
|
||||
}));
|
||||
|
||||
this.#passport = passport;
|
||||
@ -108,7 +121,7 @@ class Authenticator {
|
||||
server.OAuthProviders.forEach(provider => {
|
||||
const providerName = provider.name.toLowerCase();
|
||||
OAuthLinks[providerName] = provider.authoriseURL;
|
||||
OAuthLinks[providerName +'Token'] = provider.tokenURL;
|
||||
OAuthLinks[providerName + 'Token'] = provider.tokenURL;
|
||||
});
|
||||
|
||||
}
|
||||
@ -121,7 +134,7 @@ class Authenticator {
|
||||
* @param {object} [{ failureRedirect = '/api/login/fail', successRedirect = '/home' }={}]
|
||||
* @memberof Authenticator
|
||||
*/
|
||||
addStrategy (name: string, strategy: passport.Strategy, { failureRedirect = '/api/login/fail', successRedirect, authParams }: {failureRedirect?: string, successRedirect?: string, authParams?: OAuthParams } = {}) {
|
||||
addStrategy (name: string, strategy: passport.Strategy, { failureRedirect = '/api/login/fail', successRedirect, authParams }: { failureRedirect?: string, successRedirect?: string, authParams?: OAuthParams } = {}) {
|
||||
this.#logger.info(`Adding ${name} authentication strategy`);
|
||||
this.#passport.use(name, strategy);
|
||||
this.#OAuthParams[name] = authParams || null;
|
||||
|
Loading…
Reference in New Issue
Block a user