mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Enforce the canonical role policy for both sides of list, swimlane and checklist moves, scoped imports, attachment renames and history writes. Record denied attempts through bounded Problems summaries without allowing logging failures to bypass authorization. Add role-matrix decisions, the reported moveList attack, sibling guard inventory and a browser regression. Targeted Node suites pass; live browser execution remains pending. Thanks to Wenhao Wu, Southeast University and xet7 !
20 lines
779 B
JavaScript
20 lines
779 B
JavaScript
'use strict';
|
|
const { memberCan } = require('./boardRoleCapabilities');
|
|
|
|
// Shared by server methods and their client stubs. The capability decision is
|
|
// identical on both; only the server records attempted unauthorized writes.
|
|
function requireBoardMutation(userId, board, source, Meteor) {
|
|
if (board && memberCan(board.members, userId, 'write')) return;
|
|
if (Meteor.isServer) {
|
|
try {
|
|
require('/server/lib/securityLog').record({
|
|
key: 'authz.mutation', action: 'blocked', source,
|
|
detail: 'Board mutation denied because the caller lacks write access.',
|
|
});
|
|
} catch (e) { /* logging must never break the guard */ }
|
|
}
|
|
throw new Meteor.Error('not-authorized', 'You cannot change this board.');
|
|
}
|
|
|
|
module.exports = { requireBoardMutation };
|