ADMIN_CAN_EDIT has no effect in the web client (staff always read-only) #10

Closed
opened 2026-10-15 14:13:40 +00:00 by ben · 4 comments
Owner

Problem: the server honours ADMIN_CAN_EDIT, but the web client ignores it.

What the code does today:

  • Server: server/policy.js canWriteSession() lets the owner and, when ADMIN_CAN_EDIT=true, a linked counsellor write to a client's session. GET /api/sessions/:id reports this as readOnly (server/app.js).
  • Web client: web/src/main.ts (readOnly = !!s.readOnly || (!ownSession && (staff || …))) forces every staff member who views someone else's session into read-only, whatever the server reports. So the owner and counsellors can never edit a client's board in the UI, and setting ADMIN_CAN_EDIT=true has no visible effect.

Decision needed:

  • (a) Read-only staff review is intended. Remove ADMIN_CAN_EDIT from config and docs, or document that it only affects the API.
  • (b) The client should follow the server's readOnly flag. Edits by staff would be audited content mutations. Work out how that should look on the dashboard and in review.

Found while adding contextual help (#9). The help text currently says counsellors "may be read-only, depending on the practice's settings".

**Problem:** the server honours `ADMIN_CAN_EDIT`, but the web client ignores it. **What the code does today:** - **Server:** `server/policy.js` `canWriteSession()` lets the owner and, when `ADMIN_CAN_EDIT=true`, a linked counsellor write to a client's session. `GET /api/sessions/:id` reports this as `readOnly` (`server/app.js`). - **Web client:** `web/src/main.ts` (`readOnly = !!s.readOnly || (!ownSession && (staff || …))`) forces every staff member who views someone else's session into read-only, whatever the server reports. So the owner and counsellors can never edit a client's board in the UI, and setting `ADMIN_CAN_EDIT=true` has no visible effect. **Decision needed:** - **(a) Read-only staff review is intended.** Remove `ADMIN_CAN_EDIT` from config and docs, or document that it only affects the API. - **(b) The client should follow the server's `readOnly` flag.** Edits by staff would be audited content mutations. Work out how that should look on the dashboard and in review. Found while adding contextual help (#9). The help text currently says counsellors "may be read-only, depending on the practice's settings".
Author
Owner

Decision (maintainer, 2026-10-15): read-only staff review. The web client keeps opening every staff view of another person's session read-only.

Still to do:

  • Remove ADMIN_CAN_EDIT, or document it as API-only. Removing it touches:
    • the config in server/index.js and docker-compose.yml;
    • the policy in server/policy.js canWriteSession, the policy matrix in server/test/policy-matrix.test.js, and the related help text;
    • the docs: self-hosting §5, the API reference, the README and CLAUDE.md.
  • If the setting is removed, the server should reject staff writes to a client's session. Today the owner, and linked counsellors when the flag is on, can still write through the API.
**Decision (maintainer, 2026-10-15): read-only staff review.** The web client keeps opening every staff view of another person's session read-only. Still to do: - Remove `ADMIN_CAN_EDIT`, or document it as API-only. Removing it touches: - the config in `server/index.js` and `docker-compose.yml`; - the policy in `server/policy.js` `canWriteSession`, the policy matrix in `server/test/policy-matrix.test.js`, and the related help text; - the docs: self-hosting §5, the API reference, the README and `CLAUDE.md`. - If the setting is removed, the server should reject staff writes to a client's session. Today the owner, and linked counsellors when the flag is on, can still write through the API.
Author
Owner

Decision (maintainer, 2026-10-15): the owner loses API write access to client sessions too. Only the session's own user writes it, while it isn't archived. The owner's own sessions are unaffected. ADMIN_CAN_EDIT is removed; a leftover value is ignored, and direct (non-Compose) runs log a warning. Plan: docs/plans/2026-10-15-09-56_remove-admin-can-edit.md.

**Decision (maintainer, 2026-10-15): the owner loses API write access to client sessions too.** Only the session's own user writes it, while it isn't archived. The owner's own sessions are unaffected. `ADMIN_CAN_EDIT` is removed; a leftover value is ignored, and direct (non-Compose) runs log a warning. Plan: `docs/plans/2026-10-15-09-56_remove-admin-can-edit.md`.
Author
Owner

Implemented in 00105ed on main. Not deployed yet.

  • Server: server/policy.js canWriteSession now allows a write only from the session's own user, and only while the session isn't archived.
    • The owner and counsellors get 403 Session is read-only for any content change to another person's session.
    • The owner's own sessions are unaffected.
    • GET and SSE snapshots report readOnly for each viewer.
  • Config: ADMIN_CAN_EDIT is removed from server/index.js, docker-compose.yml and .env.example.
    • Under Compose, a leftover .env line is no longer passed to the server and is ignored.
    • A value passed to the server directly logs one warning (warnRemovedSettings in server/config.js).
  • Web: wording only, in web/src/help.ts and web/src/dashboard.ts. The client already kept staff views of other people's sessions read-only.
  • Docs: docs/self-hosting.md, docs/api.md, README.md and CLAUDE.md are updated. docs/deployment.md has a new release note, "read-only staff review (#10)". Deploying needs no migration.
  • Verification:
    • Server: 1187 tests pass.
    • Web unit: 630 pass, coverage 98.27% lines.
    • Playwright: 9 passed, 1 skipped. That includes a new e2e test where the owner edits their own board and sees a client's board read-only.
    • The policy matrix covers the staff denials, a populated client session and an owner-owned session.
    • The transaction-race and SSE-revocation tests were moved to authorized writers, so they still exercise the recheck.
    • High review: codex and deepseek (2/2).
  • Plan: docs/plans/2026-10-15-09-56_remove-admin-can-edit.md (done).

Left: deploying. This issue stays open until it's live.

Implemented in 00105ed on `main`. Not deployed yet. - **Server:** `server/policy.js` `canWriteSession` now allows a write only from the session's own user, and only while the session isn't archived. - The owner and counsellors get 403 `Session is read-only` for any content change to another person's session. - The owner's own sessions are unaffected. - GET and SSE snapshots report `readOnly` for each viewer. - **Config:** `ADMIN_CAN_EDIT` is removed from `server/index.js`, `docker-compose.yml` and `.env.example`. - Under Compose, a leftover `.env` line is no longer passed to the server and is ignored. - A value passed to the server directly logs one warning (`warnRemovedSettings` in `server/config.js`). - **Web:** wording only, in `web/src/help.ts` and `web/src/dashboard.ts`. The client already kept staff views of other people's sessions read-only. - **Docs:** `docs/self-hosting.md`, `docs/api.md`, `README.md` and `CLAUDE.md` are updated. `docs/deployment.md` has a new release note, "read-only staff review (#10)". Deploying needs no migration. - **Verification:** - Server: 1187 tests pass. - Web unit: 630 pass, coverage 98.27% lines. - Playwright: 9 passed, 1 skipped. That includes a new e2e test where the owner edits their own board and sees a client's board read-only. - The policy matrix covers the staff denials, a populated client session and an owner-owned session. - The transaction-race and SSE-revocation tests were moved to authorized writers, so they still exercise the recheck. - High review: codex and deepseek (2/2). - **Plan:** `docs/plans/2026-10-15-09-56_remove-admin-can-edit.md` (done). **Left:** deploying. This issue stays open until it's live.
Author
Owner

Deployed at ec6f0cb, together with #8. ADMIN_CAN_EDIT is no longer passed to the container: the live .env line is ignored, and the container environment no longer has it. healthz is ok and signed-out requests get 401. Staff review of a client's session is read-only on the server and in the client.

Deployed at ec6f0cb, together with #8. `ADMIN_CAN_EDIT` is no longer passed to the container: the live `.env` line is ignored, and the container environment no longer has it. healthz is ok and signed-out requests get 401. Staff review of a client's session is read-only on the server and in the client.
ben closed this issue 2026-10-16 04:20:32 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ben/career-values-cards#10
No description provided.