Skip to content

feat(cms): staff sign in to the Payload admin with Lumen (LX1) - #19

Merged
ruehowl merged 1 commit into
mainfrom
orun/LX-2-staff-sign-in
Oct 28, 2026
Merged

ruehowl merged 1 commit into
mainfrom
orun/LX-2-staff-sign-in

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

LX1 of multi-tenant-saas-2-console (task LX-2, milestone LX1). It ports sourceplane/lumen-payload#22 (PX1), adapted to the LMS as the spec (#18) lays out.

Staff (admin, editor, instructor) sign in to /admin with their Lumen account, and staff no longer have Payload passwords. Learners are untouched: they keep their own accounts and the academy's /login and /register.

What changes

  • users:
    • The local strategy is off (its columns stay) and a lumen strategy is on. It resolves the lumen_session cookie with api-edge over a new LUMEN_API service binding.
    • lumenUserId is unique and set by no request.
    • role is optional with no default; no role means pending.
    • The instructor role and its academies are unchanged, and admin access still admits all three staff roles.
  • First admin: only through the owner's setup token. After that, admins grant roles or invite by email; an invited row is linked on that person's first sign-in.
  • Pending and sign-out: Payload's unauthorized view is replaced by a pending page. Signing out revokes the Lumen session.
  • Origin guard: a request naming another origin gets no staff user (isForeignOrigin).
  • Migration 320_cms_lumen_identity, generated against this repo's snapshot. Its SQL is byte-identical to lumen-payload's 206. The converter change came with it.
  • Routes: the sign-in routes live in a new (site) group with a minimal layout; the academy keeps /.
  • api-edge CORS and identity-worker's OAuth return allowlist now include each environment's CMS origin.
  • Docs: CMS runbook, architecture and overview; operations guide; epic status. The status file lists two departures: the new (site) layout, and that when a browser holds both a staff and a learner session, the staff session wins.

Verification (local, the built Worker in workerd against stage's real api-edge)

  • Learner and staff journey through the API: 59/59.
    • Learners: the LMS's full journey still passes, covering register, enrol, lessons, quizzes, the certificate, races and the closed academy.
    • Staff: password login and first-register answer 403. A newcomer is pending, and setup makes the first admin. An invited instructor lands on their row, sees only their academy's learners, records and courses, and can't promote themself. With both sessions in one browser, the staff session wins.
  • Browser sign-in checks: 32/32. They are lumen-payload's PX1 checks (pending page, sign-out revokes, OAuth return, origin guards, sibling-Worker writes refused, no passwords).
  • Academy in a browser: 4/4. The catalogue at /, register, My learning, and a learner can't get into the admin.
  • Test suites: tests/cms 141, tests/api-edge 408, tests/identity-worker 180, tests/db 609.
  • Typecheck and lint: typecheck is clean for apps/cms and tests/cms; lint shows 0 errors.
  • The migration applies twice cleanly to a database built from 200, 300, 301 and 310.

After merge: on stage and prod, /admin shows the Lumen sign-in and password login answers 403. Stage and prod have no staff accounts yet, so nobody loses access. Opening the first admin needs the owner's CMS_SETUP_TOKEN.

Orun-Task: LX-2



Generated by Claude Code

Staff accounts (admin, editor, instructor) no longer have Payload passwords.
/admin shows a Lumen sign-in (emailed code, GitHub, Google); the session
goes into an HttpOnly cookie on the CMS host, and a `lumen` auth strategy on
`users` resolves it through api-edge over the LUMEN_API service binding and
maps the Lumen user to a `users` row. Learners are a separate collection and
keep their own accounts and the academy's /login and /register. Ported from
sourceplane/lumen-payload#22 (PX1) with the LMS's differences
(multi-tenant-saas-2-console design §2-§6).

- users: local strategy off (its columns stay), `lumenUserId` (unique, set
  by no request), `role` optional with no default: no role means pending;
  the instructor role and its academies stay, and admin access still admits
  all three staff roles
- the first admin still needs the owner's setup token; admins grant the
  rest, and inviting by email links the row on that person's first sign-in
- the pending page replaces Payload's unauthorized view; sign-out revokes
  the Lumen session
- a request naming another origin gets no staff user, so no other page (a
  sibling Worker on the same workers.dev site included) can write with the
  cookie
- migration 320_cms_lumen_identity, converted from Payload's; the converter
  accepts column default and nullability changes as idempotent
- the Lumen routes live in a (site) group with its own minimal layout; the
  academy keeps /
- api-edge CORS and identity-worker's OAuth return allowlist gain the CMS
  origin of each environment
- docs: runbook, architecture, overview, operations guide; epic status

Orun-Task: LX-2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013JuHbkZCjDrGgHdzCrCRqG
@ruehowl
ruehowl marked this pull request as ready for review October 28, 2026 21:55
@ruehowl
ruehowl merged commit a55726f into main Oct 28, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants