Files
wekan/server/permissions/lists.js
T
Lauri Ojansivu a40c4495d4 Lists: a WIP limit is set by a board admin, on every path.
The applyWipLimit, enableWipLimit and enableSoftLimit methods have always
required a board admin ("You must be a board admin to modify WIP
limits."), but a member with write access could still set wipLimit with a
plain list update - the Lists allow rule grants write members every field
- or with REST PUT /api/boards/:boardId/lists/:listId. A WIP limit is a
board-wide workflow rule, so the methods' rule now holds everywhere:

- a Lists deny rule refuses an update touching wipLimit unless the caller
  is admin of the list's board. Every WeKan client path goes through the
  methods, so it refuses nothing in ordinary use;
- the REST PUT asks for a board admin (checkBoardAdmin) when the body
  carries a wipLimit; write access still edits title, color and starred.

tests/wipLimitAdminOnly.test.cjs runs the real deny rule, pins the REST
check before the write, and fails on any list method that changes a WIP
limit without a board admin check first.

This was in CHANGELOG TODO Later as needing a maintainer decision;
decided: board admins only.

Thanks to xet7 !
2026-10-27 21:45:43 +02:00

47 lines
1.9 KiB
JavaScript

import Boards from '/models/boards';
import Lists from '/models/lists';
import { allowIsBoardMemberWithWriteAccess, denyCrossBoardMove } from '/server/lib/utils';
import { tripCanaryDeny } from '/server/lib/canary';
Lists.allow({
async insert(userId, doc) {
// ReadOnly and CommentOnly users cannot create lists
return allowIsBoardMemberWithWriteAccess(userId, await Boards.findOneAsync(doc.boardId));
},
async update(userId, doc) {
// ReadOnly and CommentOnly users cannot edit lists
return allowIsBoardMemberWithWriteAccess(userId, await Boards.findOneAsync(doc.boardId));
},
async remove(userId, doc) {
// ReadOnly and CommentOnly users cannot delete lists
return allowIsBoardMemberWithWriteAccess(userId, await Boards.findOneAsync(doc.boardId));
},
fetch: ['boardId'],
});
// Security (GHSA-gm7v-pc38-53jr): the allow rule above only checks write access
// on the list's SOURCE board, so a client could move a list into a private board
// it is not a member of by setting a new boardId. Deny any cross-board move where
// the caller lacks write access to the destination board.
Lists.deny({
async update(userId, doc, fieldNames, modifier) {
if (!(await denyCrossBoardMove(userId, modifier))) return false;
return tripCanaryDeny('list.cross-board-move', { userId });
},
fetch: [],
});
// A list's WIP limit is a board-wide workflow rule, set by a board admin: the
// applyWipLimit / enableWipLimit / enableSoftLimit methods have always required
// one, but the allow rule above let any member with write access set
// `wipLimit` with a plain list update. Every WeKan client path goes through the
// methods, so this refuses nothing in ordinary use.
Lists.deny({
async update(userId, doc, fieldNames) {
if (!fieldNames.includes('wipLimit')) return false;
const board = await Boards.findOneAsync(doc.boardId);
return !(board && board.hasAdmin(userId));
},
fetch: ['boardId'],
});