X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fauthenticator.js;h=c69ada91c6ed6a5234942b1e6ae8eb92a420d7e6;hb=7604294560bca0a026e0236ae16781684cd3a419;hp=c388ee883c60bb0fa79380696b87b9894528d209;hpb=a44a8c411be1831e7b2418212ee0b295206ca27a;p=squeep-authentication-module diff --git a/lib/authenticator.js b/lib/authenticator.js index c388ee8..c69ada9 100644 --- a/lib/authenticator.js +++ b/lib/authenticator.js @@ -66,10 +66,14 @@ class Authenticator { */ async isValidIdentifierCredential(identifier, credential, ctx) { const _scope = _fileScope('isValidIdentifierCredential'); - this.logger.debug(_scope, 'called', { identifier, credential: '*'.repeat(credential.length), ctx }); + this.logger.debug(_scope, 'called', { identifier, credential: '*'.repeat((credential || '').length), ctx }); let isValid = false; + if (typeof credential === 'undefined') { + return isValid; + } + await this.db.context(async (dbCtx) => { const authData = await this.db.authenticationGet(dbCtx, identifier); if (!authData) { @@ -266,10 +270,11 @@ class Authenticator { const cookieParts = [ sessionCookie, 'HttpOnly', - `Path=${this.options.dingus.proxyPrefix}/`, `Max-Age=${this.cookieLifespan}`, + 'SameSite=Lax', + `Path=${this.options.dingus.proxyPrefix}/`, ]; - if (this.options.authenticator.secureAuthOnly) { + if (this.secureAuthOnly) { cookieParts.push('Secure'); } res.setHeader(Enum.Header.SetCookie, cookieParts.join('; ')); @@ -282,6 +287,7 @@ class Authenticator { `${Enum.SessionCookie}=""`, 'HttpOnly', 'Max-Age=0', + 'SameSite=Lax', `Path=${this.options.dingus.proxyPrefix}/`, ]; if (this.options.authenticator.secureAuthOnly) { @@ -385,4 +391,4 @@ class Authenticator { } -module.exports = Authenticator; \ No newline at end of file +module.exports = Authenticator;