Files
wekan/models/lib/sessionList.js
T
Lauri Ojansivu a242275be8 Where I am signed in, with Sign out per session; and BACKUP_PASSPHRASE encrypts the Admin Panel backups.
The last of docs/Compliance/README.md's P3 list:

- Member Settings / Privacy and my data lists every session of the
  account - this browser first, when each signed in, and when last active
  where idle logout records it - each with Sign out, which ends just that
  one. A session is named by an opaque id, never its token or hash.
  Admin Panel / People's user popup has Log out everywhere for an account
  (adminLogoutUser, in the Audit log) (models/lib/sessionList.js,
  server/methods/sessions.js).
- BACKUP_PASSPHRASE encrypts every Admin Panel backup as it is written, to
  disk or to cloud storage: AES-256-GCM, the key stretched with scrypt, the
  salt and IV in the file's own header. A restore recognises the header,
  decrypts beside the file and removes the copy whatever happens; a wrong
  passphrase or a changed file is refused, and an older plain backup still
  restores (server/lib/backupEncryption.js). On every platform, the snap and
  the Helm chart (from a Secret).

App-level encryption of attachments on disk is left to a maintainer
decision (TODO.md): disk encryption covers it without changing every read
path.

Tested against a live server: tests/playwright/specs/backup-passphrase.e2e.js
writes an encrypted backup and restores it, and compliance-p3.e2e.js ends one
session of two. Four new strings, translated in every language. Low
confidence: ace, ak, ay, bi, bm, bua, chr, csb, cv, dz, ee, ff, fj, gn, gv,
haw, iu, kl, kok, ks, kw, lg, lld, nah, nd, nso, bo, fur, mai, bho, ary,
tig, ti, wal, ve-PP, ve-CC, ve, vo, tlh, zgh, wa, wa-RR, rup, sah, se, scn,
sc, sm, to, tpi, ts, ss, st, tn, rn, rw, ny, om, pap, qu, rm, szl, uz-AR,
ug, tt, yi, yue_CN, wuu-Hans, wo, xh.

Thanks to xet7 !
2026-11-24 05:56:38 +02:00

38 lines
1.6 KiB
JavaScript

'use strict';
// Member Settings / Privacy and my data / Where I am signed in
// (docs/Compliance/README.md P3; [GDPR] Art. 32(1)(b), [NIS2] Art. 21(2)(i)):
// every login token of the account - when it signed in, when it was last
// active where idle logout records it, and whether it is this browser - with
// a button that ends just that one. An administrator can end all of another
// account's in Admin Panel / People (adminLogoutUser, in the Audit log).
//
// A session is named by an opaque id made from its hashed token, never the
// token or its hash, so the list gives a page nothing to sign in with.
//
// Pure: the id maker is passed in (server: sha256). tests/sessionList.test.cjs.
const MAX_SESSIONS = 100;
function sessionRows(tokens, { currentHashed, lastActive = {}, idOf }) {
return (Array.isArray(tokens) ? tokens : [])
.filter(t => t && typeof t.hashedToken === 'string')
.slice(-MAX_SESSIONS)
.map(t => ({
id: idOf(t.hashedToken),
when: t.when || null,
lastActiveAt: lastActive[t.hashedToken] || null,
current: t.hashedToken === currentHashed,
}))
.sort((a, b) => (b.current - a.current) || (new Date(b.when || 0) - new Date(a.when || 0)));
}
// The hashed token a session id names, or null.
function tokenFor(tokens, id, idOf) {
if (typeof id !== 'string' || !/^[0-9a-f]{16}$/.test(id)) return null;
const t = (Array.isArray(tokens) ? tokens : []).find(x => x && typeof x.hashedToken === 'string' && idOf(x.hashedToken) === id);
return t ? t.hashedToken : null;
}
module.exports = { MAX_SESSIONS, sessionRows, tokenFor };