api: read-only users directory facade — /api/v1/users with circles authz (staff full list, circle-scoped student search)

Open
#1,226 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
mongodb, postgresql, python

Research direction

Start with the authz gate's FAMILY_OPERATIONS mapping and the circles model described in docs/circles-access-control.md, then trace how campus.api forwards requests to campus.auth. Done means the users family passes read-only gate tests for staff, students and client principals, and the facade routes rewrite and forward queries as the issue specifies. The open decision on an empty student visible set (empty result versus 403) must be settled before the work can be finished.

Written by the indexing model from the issue text.

Description

Problem

campus.auth is walled by design: mutation work there (user creation/import, session/login inspection, vault management) is admin-only, and on a daily basis routine mediation runs through the operator. Viewing the directory is the one anomaly: staff need to see and search the user list for everyday jobs (roster checks, subjcombi fixes, lookups), but the only existing path is the shared operator credential — which destroys attribution, the whole point of #854 ("domain administration must be attributable to a user").

Ratified 2026-11-24 (JS Ng): a read-only directory facade on campus.api — campus.api authorizes, rewrites the query, and forwards to campus.auth. Service boundaries are maintained: campus.api and campus.auth run separate Mongo/Postgres (Railway topology), so there are no in-process reads; forwarding is the only path.

Slice 1 — the users family in the authz gate

  • FAMILY_OPERATIONS["users"] = {"group": {"read"}, "self": {"read"}} — deliberately the only family with no write semantics; the surface cannot mutate by construction. Identity administration stays in campus.auth, admin-only, untouched.
  • Bootstrap the users grant circle and wire it into the root family set (same as the other resource circles).
  • Staff pass group-read via the staff:viewer baseline → full list.
  • Students get no users baseline — their visibility comes from the circle-scope computation below. Their student primary-group membership sits at guest, which carries no group-read, so the platform roster never leaks through the baseline.
  • Field masks: group read = directory fields (id / email / name / activated_at — the whole User record today); self read = the caller's own record.
  • require_user_principal on every route (#854); client principals denied on the facade.
  • Spec update (docs/circles-access-control.md) + gate tests.

Slice 2 — facade routes: authz → query rewrite → forward

  • GET /api/v1/users — paginated (prod has ~1,562 users), ?limit/?cursor, ?q= substring search over name/email.
  • GET /api/v1/users/<user_id> — single record; any authenticated user may fetch their own record (self read).
  • Scope computation, then the query rewrite, then the forward:
    • Staff caller (users family group-read via baseline): forward the paged/search query as-is.
    • Student caller: visible set = union of member ids across circles where the caller's own membership value carries group-read (viewer). Forward an id-set-filtered query with the search term applied within the set. Design notes: a circle membership at guest confers nothing; viewer/editor/admin on the circle confers directory read of its members — so "student leader of a club" needs no extra role logic. Empty visible set → empty result or 403 (decide at PR).
    • Neither → 403.
  • Forwarding: service-to-service call to campus.auth's existing user-query surface using a dedicated campus.api service OAuth client holding users:read in the grant store (minted by the operator). This is the grant store's only participation: it gates the service client at auth's management boundary, while campus.api's own authz never consults the grant store (boundary intact, per the authz module note). Precedent for service clients holding users:read: #1189 (flask_campus identity re-fetch).
  • End-user attribution lives on the facade: every call carries a user principal and lands in campus.audit under that user, not the service client.
  • OpenAPI regen (all services, sort_keys ritual).

Out of scope

  • Seeding class/CCA member-list circles — a separate data slice; the student scope works the moment such circles exist with member access at viewer, and students see an empty search until then (today's behavior anyway).
  • Any mutation surface; any campus-model change (none needed: User carries the directory fields, groupings ride the existing circles mechanism, search/pagination are API parameters).

Dependency for: ttv2#174 (import-time teacher-name resolution), ttv2#175 (browse pickers). Follow-up: SDK + CLI surface (separate issue).

Dominant language
Python
Stars
0
Forks
2
Avg merge
39m
Merged PRs (30d)
235

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nyjc-computing/campus

All issues in nyjc-computing/campus

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.