mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
Enable Meteor 3 native HttpOnly resume authentication with in-memory client credentials, remove the JavaScript cookie and local-storage synchronization, and harden header-login cookies. Thanks to binary-lover and xet7 !
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
|
|
const client = read('client/00-startup.js');
|
|
const server = read('server/accounts-common.js');
|
|
const headerLogin = read('server/header-login.js');
|
|
|
|
for (const [where, source] of [['client', client], ['server', server]]) {
|
|
assert.match(source, /clientStorage: 'none'/,
|
|
`${where} must not persist the resume token in Web Storage`);
|
|
assert.match(source, /useHttpOnlyCookies: true/,
|
|
`${where} must enable Meteor's native HttpOnly resume flow`);
|
|
}
|
|
|
|
assert.doesNotMatch(client, /document\.cookie\s*=/,
|
|
'client JavaScript must never create a readable authentication cookie');
|
|
assert.doesNotMatch(client, /_storedLoginToken|_storeLoginToken/,
|
|
'custom token copying must not bypass the native in-memory flow');
|
|
assert.match(headerLogin, /\['Path=\/', 'SameSite=Lax', 'HttpOnly'\]/,
|
|
'header login must issue its authentication cookies as HttpOnly');
|
|
assert.match(headerLogin, /cookieBase\.push\('Secure'\)/,
|
|
'HTTPS header login must retain Secure in addition to HttpOnly');
|
|
|
|
console.log('httpOnlySessionCookie: 8 assertions passed');
|