Skip to content

fix(access): a published client key reads every manager's name and email - #825

Merged
sydevs-bot merged 11 commits into
mainfrom
claude/fix-821-managers-access
Sep 21, 2026
Merged

sydevs-bot merged 11 commits into
mainfrom
claude/fix-821-managers-access

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • managers joins RESTRICTED_COLLECTIONS. No client role gets a grant back; atlas-manager gets the only one, because it picks on Events.manager and Regions.managers.
  • Two fields on events hold a manager's address as a value, which no collection-level rule reaches: registrationNotificationEmail, and activityLog — a seventh path found during review, not in the ticket.
  • tests/int/managers-access.int.spec.ts asserts every path through overrideAccess: false. Each of four defects was reintroduced and watched fail.

Changes

  • src/plugins/access/config/projects.ts — 'managers' in the restricted set
  • src/plugins/access/config/roles.ts — atlas-manager gains managers: ['read']
  • src/collections/Events/Events.ts — managersOnlyFieldAccess on registrationNotificationEmail
  • src/fields/logField.ts — the factory's access gains a read, so every activityLog inherits it
  • src/collections/Forms/fields.ts, src/plugins/access/permissions.ts — comments the change makes false
  • docs/rules/access.md — managers in the restricted list, and the field-lock section rebuilt around the four fields that carry the lock
  • tests/int/managers-access.int.spec.ts (new), and tests/int/atlas-report-issue-form.int.spec.ts, whose Forms.recipient case now asserts a bare id — that is what separates the lock passing the field through from the lock stripping it

Preview

  • Events list — the admin is unaffected; nav visibility gates on write, not read
  • Any event's editor — "Send Registration Updates To" still renders and saves for a manager
  • Managers list — still reachable as an admin

The API half needs a published client key, so it is not a link — the integration spec is the evidence.

Migration

None. Field access and role grants are runtime config; no column changes, so db:migrations:create was not run.

Test results

  • Lean gate: ✓ lint, typecheck, typecheck:tests, test:unit (2144 passed)
  • Full integration lane: ✓ 82 files, 1341 passed — run twice, because the change is global and logField is shared
  • New spec: 11 passed
  • Build: N/A (Railway builds the preview)

Every review round since has been comment-only — git diff 3139dd3..HEAD changes no non-comment TypeScript line — so the lean gate was re-run each time and the integration lane was not.

Manual verification

  1. With a published sahaj-atlas-client key, GET /api/managers?select[id]=true → 403.
  2. GET /api/events?select[activityLog]=true&select[registrationNotificationEmail]=true with that key → neither key present.
  3. As an atlas-manager, open an event and confirm the Manager picker lists other managers.
  4. As a web-translator, open a page's Page Editors sidebar: it now shows a raw id instead of a name. Intended — see Notes.

Notes for reviewer

The seventh path is the part worth your attention. logField declared create and update access and no read. A reminder entry records destination — "the address/handle the reminder went to", a manager's email or a WhatsApp/Telegram/WeChat handle — and escalations log the region managers above the event too. GET /api/events?select[activityLog]=true returned all of it to the widget's browser key. The lock went in the factory, so user-submissions.activityLog and the next consumer inherit it.

One accepted regression, already settled on the ticket: web-translator loses the Pages.managers picker label and renders a raw id. Cosmetic, one role, one admin field.

A latent trap found while reviewing, not touched here. applyFieldAccessForTranslatableCollections injects role-aware field access only where !field.access, so a hand-written access block silently replaces it. Harmless today — events is not translatable — but it would bite if events ever gained a translate grant.

Detail

Why the four relationship fields need no lock. Payload's relationshipPopulationPromise populates through the dataloader at the parent's overrideAccess, with disableErrors: true, and falls back to the bare id when the related read returns nothing — its own comment says "ids are visible regardless of access controls". Verified in node_modules, and asserted for events, regions and clients in the new spec.

Fixture pre-mortem, and it caught something. The activityLog fixture assumes an event's log survives a write. It does not: syncVerificationOnSave (src/collections/Events/hooks/syncVerificationOnSave.ts) resets activityLog to a single re-save entry on any managed save, so a log passed to the create is discarded. The seed now writes under context: { skipVerifyHook: true } and builds the entry through the real buildReminderEntry. Without that, the assertion would have passed vacuously — the first fixture case is what caught it.

Why !== 'clients' on logField rather than managersOnlyFieldAccess. The admin verify action writes the log with overrideAccess: false, so read has to admit whatever the two write keys beside it already admit. An anonymous caller never reaches it — hasPermission denies a null user at collection level. The code now carries that equivalence itself, rather than leaving it here.

clients at depth >= 1. The ticket warns this check goes vacuous if #822 restricts clients first. It asserts on a row the key can read today; if #822 lands first, that case needs revisiting.

Adopted from the adversarial review pass. Two consider findings, both about the new prose. logField's read now states why it stays a denylist (ca14320). The relationship-vs-copy rule stands once, at docs/rules/access.md:210, instead of five times across four files (8d40d21) — the two call-site comments stay, because that is where someone trips over it.

Adopted from @Ardnived's review. Both findings landed on those same two comments, and both are fixed. Events.registrationNotificationEmail's lock is now explained in ordinary words — a copy of an address, and hiding the collection does not hide a copy — instead of "denormalized" and "reaches a relationship, never a copy" (a5ed0ec). logField's access comment is 11 lines instead of 24, with all three rules kept and the narrative left to docs/rules/access.md (89b2f19).

Dismissed review findings. Lifting managerReq into tests/utils/testHelpers.ts, and exporting a shared managersOnlyAccess object to replace the four hand-copied three-key literals — both are refactors of code this PR does not otherwise touch, so they widen the diff past the ticket. Worth filing separately. The reviewer also suggested dropping the create/update assertions from the client-roles case as unreachable; kept, because the acceptance criterion is "no client role holds a managers grant", not "no read grant".

Also checked and clean: every collection: 'managers' call site under src/ passes overrideAccess: true or relies on the Local API default, so no server-side reader degrades. The atlas SEO, sitemap and geojson endpoints read at overrideAccess: false with explicit selects that never name a manager. managers was already in the OpenAPI spec's always-hidden set.

Closes #821

🤖 Generated with Claude Code

https://claude.ai/code/session_01TU4aJFfuUtqbPqfvp9fqnc

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

`managers` sat in no project. For read that is not restrictive — implicit
read treats "no project" as shared, so every published API key, the Atlas
widget's browser key included, could list every manager's name and email
address. Directly through `GET /api/managers`, and at `depth >= 1` through
`Events.manager`, `Regions.managers`, `Pages.managers`,
`Clients.managers` and `Clients.primaryContact`.

`RESTRICTED_COLLECTIONS` is the mechanism for exactly this, and `users` is
the precedent: restricted for the same reason, with `atlas-manager` given
its read back explicitly.

No client role gets a compensating grant. Nothing in SahajCloud,
SahajAtlasWeb or WeMeditateWeb asks a client to read a manager — every
SahajAtlasWeb fetcher passes an explicit `select` and none names
`manager`, and WeMeditateWeb narrows `EMBEDDED_FORM_SELECT` expressly so a
form's `recipient` never reaches the browser.

`atlas-manager` gets `managers: ['read']`, because it holds create/update
on events and regions and so resolves both pickers. Collection-wide on
purpose: a picker exists to list *other* managers, so a self-scoped
`Where` would empty it. `web-translator` gets nothing — `Pages.managers`
is `adminOnlyFieldAccess` on update, and `translate` reaches localized
fields only. The cost is a raw id in the Page Editors sidebar for that one
role on that one field.

The four relationship fields need no lock of their own: populate refuses
the related read and falls back to the bare id, which Payload's own
`relationshipPopulationPromise` states outright. `Forms.recipient`'s
existing lock becomes defence in depth, so its `⚠` — which justified
itself by saying `managers` was unrestricted — is corrected rather than
kept as a false claim.

Admin navigation is unaffected: `createHidden` gates on write permission,
and no role grants write on `managers`. Document-level manager access is
unaffected: every query in `documentManagers.ts` passes
`overrideAccess: true`.

Refs #821

Co-authored-by: Claude <[email protected]>
The sixth path to a manager's address, and the one restricting the
`managers` collection cannot close: this field holds a *copy* of the
address, not a relationship to the manager, so no collection-level rule
reaches it. It carried no field access, and `events` is in the
`sahaj-atlas` project, so `sahaj-atlas-client` read it at any depth.

It is where registration updates are redirected, and its placeholder is
`Event Manager` — blank means the event manager, so a non-blank value is
an address someone chose to expose to the CMS, not to the widget. The
widget never asks for it: SahajAtlasWeb's event fetcher selects
`contactPhone` and `contactName` only.

`managersOnlyFieldAccess` is the same helper `Forms.recipient` carries and
admits any manager, so `atlas-manager` still reads and writes it.
`contactEmail` beside it stays open — that one is the address a seeker is
meant to write to.

Refs #821

Co-authored-by: Claude <[email protected]>
`tests/int/managers-access.int.spec.ts` covers all six paths through
`payload.find` with `overrideAccess: false`, shaped like
`user-submissions-access.int.spec.ts`. A `hasPermission` assertion would
not do: a collection's own `access` block outranks the generated one, so
the predicate can answer "denied" while the composed config still serves
rows. The one `hasPermission` case is about role configuration — that no
client role carries a grant — which is what a predicate is right for.

Two vacuous-pass traps are closed explicitly. A client read carrying no
`select` is refused 400 by the usage plugin before access runs, so a bare
`rejects.toThrow()` would go green against a wide-open collection: every
read declares `select`, and the refusal asserts 403. And a populate that
falls back to a bare id looks identical to a relationship that was never
seeded, so the first case reads every fixture back as an admin and
asserts the manager's email is really there.

Each of the three defects was reintroduced and watched fail: dropping the
`RESTRICTED_COLLECTIONS` entry reds 5 cases, dropping the field lock reds
1, dropping the `atlas-manager` grant reds 2.

`atlas-report-issue-form.int.spec.ts` asserted a populated `recipient` for
a `web-translator`. That role holds no `managers` grant now, so the value
is a bare id — the accepted cost, not a regression. The case now asserts
the field survives and carries the recipient's id, which still tells "the
lock let it through" apart from "the lock stripped it", and a new sibling
case pins the other half: an `atlas-manager`, which has the grant, still
gets the populated manager.

Refs #821

Co-authored-by: Claude <[email protected]>
`docs/rules/access.md` named `managers` as sitting in no project and so
"shared, readable by every role". That sentence was written as a
description of the mechanism and was the documentation half of #821 — it
described the exposure without anyone reading it as one.

It now names the restricted set correctly, says no client role gets a
grant back, and records the one accepted cost: `web-translator` renders a
raw id in the Page Editors sidebar.

The field-lock section gains `Events.registrationNotificationEmail` as its
fourth field, and states the distinction that section previously had no
reason to draw — a collection-level restriction reaches a relationship, a
field lock is what reaches a denormalized copy. `Forms.recipient`'s
justification moves with it, since the lock is now defence in depth.

The `clients` paragraph is left to #822.

Refs #821

Co-authored-by: Claude <[email protected]>
A seventh path to a manager's address, found reviewing the six this
ticket set out to close. `logField` declared `create` and `update` access
and no `read`, so the column was readable by anyone who could read the
document — and `Events.activityLog` sits on a collection in the
`sahaj-atlas` project. `GET /api/events?select[activityLog]=true` with
the widget's published browser key returned it.

What it holds is not incidental. A reminder entry records `destination`,
"the address/handle the reminder went to" — a manager's email, or a
WhatsApp, Telegram or WeChat handle from their contact details. Escalation
entries add the region managers above the event, who have no relationship
to it at all. And `actorFromUser` falls back to an address when a manager
has no name, so `by.name` can be one too.

Restricting the `managers` collection cannot reach this: a JSON column
holds copies, not a relationship. The lock goes in the factory rather than
on the field, so `user-submissions.activityLog` inherits it and so does
the next consumer.

`!== 'clients'` rather than `managersOnlyFieldAccess`, matching the two
keys beside it: the admin verify action writes this log with
`overrideAccess: false`, so the predicate has to admit whatever the two
write keys already admit.

Refs #821

Co-authored-by: Claude <[email protected]>
From the review pass over the branch. Behaviour is unchanged except for
one test that was not testing what it said.

- The `⚠` on the `RESTRICTED_COLLECTIONS` entry enumerated the six paths
  and contradicted itself doing it — "five of them close here" over a list
  of one endpoint and five fields, then "those four fields". A census also
  goes stale the day a field is added. It now states the rule that does
  not: this entry reaches a relationship, never a copy.
- `Forms.recipient`'s comment narrated what this branch did to the
  previous comment. `docs/rules/code-comments.md` rules that out, and the
  durable half is the last sentence.
- The new spec built its own client request. `createClientAuthenticatedRequest`
  and `idOnlySelect` already exist, and the latter's JSDoc owns the
  400-vs-403 hazard the header was restating.
- `it('still reads contactEmail')` selected and asserted `contactName`.
  The event fixture now seeds a contactEmail and the case reads it back —
  it is the contrast both locks lean on, so it has to be the field tested.
- `statusOf` was nine lines and one call site for what
  `rejects.toMatchObject({ status: 403 })` says inline.
- The `atlas-report-issue-form` case added for the `atlas-manager` grant
  duplicated the managers-access spec's own, from the wrong file and with
  a fixture seeded mid-test. Dropped; the redundant `toHaveProperty`
  beside it went with it.

Refs #821

Co-authored-by: Claude <[email protected]>
Follows the code. The field-lock section became a four-bullet list, one
per locked field, so the next lock is added without re-flowing a
ten-line paragraph carrying three `⚠`.

The distinction the section now leads with is the one this ticket paid
for twice: `RESTRICTED_COLLECTIONS` reaches a relationship to a
collection, and only a field lock reaches a copy of its data.
`Events.registrationNotificationEmail` and `Events.activityLog` are both
copies, and neither was closed by the list.

Also corrects the description of `managersOnlyFieldAccess`. It was
written as a denylist ("denies any caller whose collection is clients")
and is spelled as an allowlist, which denies an anonymous caller too.

Refs #821

Co-authored-by: Claude <[email protected]>
@railway-app

railway-app Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-825 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 21, 2026 at 9:59 pm UTC
1 service not affected by this PR
  • mailpit

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-825 September 21, 2026 18:38 Destroyed
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 21, 2026
@sydevs-bot

sydevs-bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 21:52Z address-review · attempt 1 · session · done
  • 21:52Z address-review · attempt 1 · session
  • 18:57Z address-review · attempt 1 · session · done
  • 18:57Z address-review · attempt 1 · session
  • 18:50Z adversarial-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff is the size of its ticket: ~60 production lines over five files, plus a 315-line spec. Events.activityLog is a real seventh path, and the logField factory is the right level to lock it. No blockers. Both findings are about the new prose and the new predicate, not the fix.

Findings

  • consider — the new read is a denylist, while access.md in this same diff calls the lock an allowlist (src/fields/logField.ts:222).
  • consider — "reaches a relationship, not a copy" is stated five times in four files (src/plugins/access/config/projects.ts:175).

Checked

atlas-manager is the only role with write on events or regions, so one grant is right. hasPermission denies a null user and users is non-auth, so the denylist is equivalent today. Swept every overrideAccess: false read in src/: gateRegistration.ts:48 reads an event as a client and touches no locked field; the atlas seo, sitemap and geojson selects name none. Both consumer repos name the locked fields only in generated types.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/fields/logField.ts Resolved
Comment thread src/plugins/access/config/projects.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 21, 2026
The `read` predicate reads as inconsistent beside `access.md`, which calls
`managersOnlyFieldAccess` an allowlist in the same diff. The predicate stays:
all three keys must admit the same callers, because the verify action writes
the log at `overrideAccess: false` with a manager's own permissions. The
comment now carries the equivalence proof instead of leaving the reader to
re-derive it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016YoK9Qzru3y85rHHRvVcCr
The rule stood five times across four files. The two call-site comments earn
their place, because that is where someone trips over it. The restricted-list
entry now carries the grant plus a pointer, and `access.md` states the rule
once, in the section that owns the list, rather than restating it two sections
later.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016YoK9Qzru3y85rHHRvVcCr
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-825 September 21, 2026 19:03 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both adversarial findings adopted. Pushed 8d40d21.

Nothing rebutted, nothing asked. Comment-only: git diff 3139dd3..HEAD changes no non-comment TypeScript line, so the lean gate was re-run green and the integration lane was not.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 21, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 21, 2026 19:15
@sydevs-bot
sydevs-bot requested a review from Ardnived September 21, 2026 19:15
Comment thread src/collections/Events/Events.ts Resolved
Comment thread src/fields/logField.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 21, 2026
The comment said "denormalized" and "reaches a relationship, never a
copy" — accurate, and unreadable to anyone who has not read
docs/rules/access.md. State the same fact in ordinary words: the field
holds a copy of an address, and hiding the collection does not hide a
copy.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BAN4NMPCSiP6gco2Kjp21Q
24 lines for a three-key access block. Every rule survives — the
admin.readOnly caveat, why the verify action must not be denied, and
why read is a denylist — stated once each instead of as a narrative.
The full story stays in docs/rules/access.md.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BAN4NMPCSiP6gco2Kjp21Q
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-825 September 21, 2026 21:56 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both findings adopted, both threads resolved. Pushed 89b2f19.

Nothing rebutted, nothing asked. Comment-only again: git diff 3139dd3..HEAD changes no non-comment TypeScript line, so the lean gate was re-run green and the integration lane was not.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 21, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit f076b6d Sep 21, 2026
23 of 26 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-821-managers-access branch September 21, 2026 22:16
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 21, 2026
sydevs-bot pushed a commit that referenced this pull request Sep 21, 2026
`main` landed #825, which restricts `managers` and edits the same three
places this branch does. Both restrictions are wanted, so every hunk keeps
both sides.

- `RESTRICTED_COLLECTIONS` holds `managers` and `clients`. Both docblock
  entries stay. The holding-pattern note said `managers` was the one
  collection left outside the set and that #821 blocked the real fix; #825
  settled that, so the note now says all four out-of-project collections are
  named and the set fails open on the fifth.
- `permissions.ts` step 4a keeps `main`'s pointer to `config/projects.ts`
  and this branch's note that self-access already answered a client's own
  row.
- `docs/rules/access.md` keeps both ⚠ sets. `clients` is no longer an
  example of "in no project, so shared", the field-lock list is five fields
  rather than four, and the two claims each side made about the other's
  collection being unrestricted are corrected.

`managers-access.int.spec.ts` needed two fixes the merge exposed. It passed
`String(client.id)` to `createClientAuthenticatedRequest`, which takes a
`number` on this branch — the stringified id denies a client its own row
through the self-access bypass. And its depth-1 `clients` case read a list,
which restricting the collection now refuses outright: the case is split
into the 403 and a self-access `findByID` of the caller's own row, which is
where #821's property still has to hold. Both were watched failing with the
restriction dropped.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0191PvAdP7nkRiqAno9irxaE

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-825 — 89b2f195 Deployed Sep 21, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(access): a published client key reads every manager's name and email

3 participants