minor cleanups
[squeep-authentication-module] / lib / authenticator.js
index c69ada91c6ed6a5234942b1e6ae8eb92a420d7e6..ba5d9217a86ca03efdaebd07c7b833338ddc7cce 100644 (file)
@@ -51,7 +51,8 @@ class Authenticator {
       throw new Error('no authentication mechanisms available');
     }
 
-    this.mysteryBox = new MysteryBox(logger, options);
+    this.mysteryBox = new MysteryBox(options);
+    this.mysteryBox.on('statistics', common.mysteryBoxLogger(logger, _fileScope(this.constructor.name)));
 
     this.cookieLifespan = options.authenticator.inactiveSessionLifespanSeconds || 60 * 60 * 24 * 32;
   }
@@ -86,7 +87,7 @@ class Authenticator {
         &&         this.authnEnabled.includes('pam')) {
           isValid = this._isValidPAMIdentifier(identifier, credential);
         } else {
-          this.logger.error(_scope, 'failed, unknown type of stored credential', { identifier, ctx });
+          this.logger.error(_scope, 'failed, unknown or unsupported type of stored credential', { identifier, ctx });
         }
       }
 
@@ -188,7 +189,7 @@ class Authenticator {
     (cookieHeader || '').split(/; */).forEach((field) => {
       const [ name, value ] = common.splitFirst(field, '=', null).map((x) => x && decodeURIComponent(x.trim()));
       if (name && !(name in cookie)) {
-        if (value && value.startsWith('"') && value.endsWith('"')) {
+        if (value?.startsWith('"') && value.endsWith('"')) {
           cookie[name] = value.slice(1, -1); // eslint-disable-line security/detect-object-injection
         } else {
           cookie[name] = value; // eslint-disable-line security/detect-object-injection