Repository navigation
fix(host): let the Project role switch reach its handler on a signed-in host (#1836) - #1837
Conversation
cacc986 to
d0be5d5
Compare
|
@Birfy — review request for this tip.
What it changes, and why:
The pull request body carries the red-first run, the |
channel.js already dispatched project-role and store.js already implemented it, but the name was missing from authz.js's explicit TASK_ENDPOINTS list, so a host with a member session refused it as Unknown endpoint before the handler ran. Fixes ThinkFlowLab#1836 Tests: core/test/project-role-authz.test.js
|
Verdict: PASS at d0be5d5 Ran at this tip: Review points:
Not run: the smoke test (no |
Written-by: Dev-4
Owner: Dev4
Reviewer: Birfy
Fixes #1836
What was wrong
The Project role switch
#1832shipped is a write the channel already dispatches and the store already implements:channel.jshascase 'project-role'andstore.jshas theproject-rolecase that runschangeRole(project-board.js). The only missing piece was its line inauthz.js's explicitTASK_ENDPOINTSlist, so on any host with a member session (state.authSessionsnon-empty) the gate answeredbot/not-found: Unknown endpoint project-roleatauthz.js:429before the handler could run, and the role menu failed everywhere it was used.Red first
Base
f245520cbbcb7de1931a91c07c675e20dbe9fc79(live main at push time), tree93fd71e4986c36b13ac79cf5dff42224a60f8cae. Clean checkout at that base, source untouched, onlycore/test/project-role-authz.test.jsplaced in the tree,node --import ./test/harness-resolve.mjs --test test/project-role-authz.test.js:Only
project-rolewas unclassified: no second dispatched endpoint surfaced, over all 110 case labels of the channel's oneswitch (endpoint).What changed
core/src/host/authz.js:'project-role'joinsTASK_ENDPOINTS, with a comment naming core: a signed-in deployment answers "Unknown endpoint project-role", so #1832's role switch writes nothing #1836 and the family —channel.jsdispatches it,store.jsimplements it, and the policy in front of the write ischangeRole, which refuses a non-owner itself.patches/ds-bot/files/src/host/authz.js: the same bytes (authz.js is a FlyBot-added file, so the mirror is the whole file). No.patchin the series changes;ds-bot-patches checkprovescore/equalsds-bot/+patches/ds-bot/.docs/subsystems/core-host.md: theproject-roleparagraph now says the endpoint is listed since core: a signed-in deployment answers "Unknown endpoint project-role", so #1832's role switch writes nothing #1836, the third of the family afterproject-board(core: the merged project-board endpoint is denied when authz is on, and a run binding can put another Project's card on the board #1713) andproject-assistant-owner(Project assistant settings: dispatch project-assistant-owner through channel and authz (gates come from #1743) #1759), and names the guard test.changelog.d/1836-project-role-authz.fixed.md.The guard: an asset, not a patch
#1713and#1759each added one line and left no guard behind, which is why the third occurrence slipped through the same hole. This test blocks the class instead of the instance: it reads everycase '<name>':label ofchannel.js'sswitch (endpoint)(110 today, deduplicated), callsrt.authorize(actor, name, {})on a lightweight in-memory runtime with oneauthSessionsentry (no server, no network, no disk), and collects all violations before asserting — a fail-fast would reveal one missing name per red run. Each violation is printed asname -> code: message, e.g.project-role -> bot/not-found: Unknown endpoint project-role.It distinguishes the three answers the gate may give: ALLOW, a refusal with a reason (
bot/forbidden,bot/unauthorized, ...), andbot/not-found— only the third is a violation, and the test asserts all three shapes occur so the check is not vacuous. A reverse sanity case keeps the other end honest: a name the channel does not dispatch still answersbot/not-found: Unknown endpoint no-such-endpoint. The file lives incore/test/, sonpm --prefix core testandnpm run verifycollect it; the whole suite runs in under a second.Files
334 insertions, 2 deletions, 6 files.
Acceptance (the five items on the issue)
changed: truewithroles: {maintainers: [], members: ['plain-1','maint-1']}, theprojectsread back for the same actor saysrole: 'member', andstate.jsonholds the sameroles.changeRoleand returns{changed: false, reason: 'not-owner'}, and the stored Project record is byte-identical afterwards — the Projects 导航与项目角色:点项目直达看板,右键切 Owner/Maintainer/Member #1828 policy is untouched (it lives inproject-board.js, not in authz).bot/unauthorized/Sign in first, unchanged.authz.test.js21/21,project-roles.test.js5/5,project-board.test.js17/17, plus the new file 4/4.Gates
arch-docs: OK (6 changed file(s))withARCH_DOCS_BASE=f245520c.npm run verifyexit 0 at this head: core 2207/2207, plugins social 541/541, the other plugin suites green,.github/scripts24/24, interop and live-e2e green.Where to read it
Checkout
/home/xuke/.dsh/bot/workspace/w1836, branchdev/4-p245-project-role-authz, headd0be5d5e58ad4238c3f5e6112709e6bda80dacbf, treeb8e0aa5b1a8cda2714fbc32601cb2f0510a37541, basef245520cbbcb7de1931a91c07c675e20dbe9fc79.git diff f245520c -- core/src/host/authz.jsis the one line plus its comment.