X-Git-Url: http://git.squeep.com/?p=squeep-authentication-module;a=blobdiff_plain;f=lib%2Fauthenticator.js;h=c388ee883c60bb0fa79380696b87b9894528d209;hp=1cff2108f309e2ac51245070281e0ec346f6168c;hb=a44a8c411be1831e7b2418212ee0b295206ca27a;hpb=afa866e6bb4d5af652379295c9497c2caf4ecc92 diff --git a/lib/authenticator.js b/lib/authenticator.js index 1cff210..c388ee8 100644 --- a/lib/authenticator.js +++ b/lib/authenticator.js @@ -20,6 +20,7 @@ class Authenticator { * @param {Boolean} options.authenticator.secureAuthOnly * @param {String[]} options.authenticator.forbiddenPAMIdentifiers * @param {String[]} options.authenticator.authnEnabled + * @param {Number=} options.authenticator.inactiveSessionLifespanSeconds * @param {String[]=} options.authenticator.loginBlurb * @param {String[]=} options.authenticator.indieAuthBlurb * @param {String[]=} options.authenticator.userBlurb @@ -51,6 +52,8 @@ class Authenticator { } this.mysteryBox = new MysteryBox(logger, options); + + this.cookieLifespan = options.authenticator.inactiveSessionLifespanSeconds || 60 * 60 * 24 * 32; } @@ -259,6 +262,17 @@ class Authenticator { && (ctx.session.authenticatedIdentifier || (profilesAllowed && ctx.session.authenticatedProfile))) { this.logger.debug(_scope, 'valid session cookie', { ctx }); + // Refresh timeout on valid session. + const cookieParts = [ + sessionCookie, + 'HttpOnly', + `Path=${this.options.dingus.proxyPrefix}/`, + `Max-Age=${this.cookieLifespan}`, + ]; + if (this.options.authenticator.secureAuthOnly) { + cookieParts.push('Secure'); + } + res.setHeader(Enum.Header.SetCookie, cookieParts.join('; ')); return true; }