test coverage for allowed insecure cookies
authorJustin Wind <justin.wind+git@gmail.com>
Mon, 6 Jun 2022 18:22:35 +0000 (11:22 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Mon, 6 Jun 2022 18:22:35 +0000 (11:22 -0700)
lib/authenticator.js
test/lib/authenticator.js

index 4449a94b700889f5c2196b77c91872ed0b52d26d..c69ada91c6ed6a5234942b1e6ae8eb92a420d7e6 100644 (file)
@@ -274,7 +274,7 @@ class Authenticator {
         '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('; '));
index 5da64397118439ff57cff5e414a83c8bfb3d6da7..9fa220097d09b0112fc1649defb7e67efe0c3fca 100644 (file)
@@ -305,6 +305,16 @@ describe('Authenticator', function () {
       const result = await authenticator.sessionCheck(req, res, ctx, loginPath, required, profilesAllowed);
       assert.strictEqual(result, true);
     });
+    it('covers valid insecure cookie session', async function () {
+      authenticator.secureAuthOnly = false;
+      req.getHeader.returns(cookie);
+      sinon.stub(authenticator, 'isValidCookieAuth').resolves(true);
+      ctx.session = {
+        authenticatedIdentifier: 'user',
+      };
+      const result = await authenticator.sessionCheck(req, res, ctx, loginPath, required, profilesAllowed);
+      assert.strictEqual(result, true);
+    });
     it('rejects insecure connection', async function () {
       ctx.clientProtocol = 'http';
       try {