Repository navigation
feat(admin): admin panel signs in through auth.cubityfir.st; sync account deletions - #25
Merged
Merged
Conversation
The admin panel is its own first-party OIDC client (scopes openid profile email roles; sign-in requires the admin role, re-checked live via the identity service). It reuses the API worker's sign-in flow (now a shared AuthFlow: login/callback/exchange/logout) with an 'admin' session kind, and server-side OIDC requests go over the IDENTITY_OIDC service binding. Removed what moved to auth.cubityfir.st: the docs-app handoff, the OAuth clients tab, and account moderation (disable/suspend/re-enable, force password change). Standing shows as read-only from the users mirror, with a live refresh in user details and links to manage the account there. Delayed deletion now deletes Annex data only: scheduling blocks the person from Annex, the cron removes sites/orgs the operator confirmed, Stripe, memberships, billing, preferences and sessions, and marks the schedule completed. The users row and schedule stay, so they remain blocked until the identity account is deleted on auth.cubityfir.st. All admin data now lives in cubedocs-main; no AUTH_DB or AUTH binding.
An hourly cron polls IdentityService.listDeletedUsers from the newest deletion already recorded in identity_deletions and removes each deleted account's Annex data: the Stripe customer (cancelling Ink), memberships, API keys, doc shares, favourites, avatars and the users mirror row (cascading sessions, billing, preferences and any admin deletion). Sites and organizations they owned are kept with their owner rows and listed in the admin panel's Projects page for an operator to review. Failures (e.g. Stripe) stay pending with last_error and retry hourly. Drops cleanupDeletedAccount, which deleted owned sites and had no caller left after DELETE /me moved to the identity service.
…e2e to the new sign-in (#26) * chore: remove packages/auth (annex-auth) now that nothing depends on it Identity lives on auth.cubityfir.st and everything Annex-specific moved into the api worker, so the annex-auth worker package goes: root dev/build/deploy/typecheck/test scripts, the auth migrations step, d1-local's "auth" database and e2e's auth-DB calls (account data is in cubedocs-main now). The cubedocs-auth schema survives as a fixture for the one-time import script. Admin + admin-frontend tests join the root `pnpm test`, and `dev:stripe` forwards to the api worker. Adds e2e/signIn.ts (dev quick-login) for porting the e2e suites, which still drive Annex's old registration and login forms. * docs: describe Annex as a client of auth.cubityfir.st CLAUDE.md's auth section, schema notes, admin deletion, worker config and local-dev notes now describe the OIDC client model: Annex sessions and the users mirror in cubedocs-main, the IDENTITY RPC and IDENTITY_OIDC bindings (and why same-zone fetches must use the binding), the deletion sync, and the e2e suites that still need porting. New memories/Identity-Client.md covers the flow, client registration and the cutover steps; .dev.vars.example files show how to point local dev at a local identity worker. Ink-Stripe, Api-Keys, Collab, Worktree-Dev, README and CONTRIBUTING drop the auth worker. * fix(oidc): harden sign-in handoff, deletion and billing paths after review - The single-use handoff code now travels only in an HttpOnly, SameSite=Strict cookie (never in a URL), so a crafted /auth/complete link can't sign anyone in (login CSRF). - A recorded or persisted identity deletion wins over the standing cache, the mirror fallback and any in-flight mirror refresh (sessions, API keys, collab); deleted owners' kept member rows are scrubbed. - Admin deletion: the live admin role is required at scheduling and re-checked before execution; the point of no return is tied to the Stripe customer the preflight saw. - Stripe webhook: billing upserts are guarded against tombstones; a blocked event deletes its customer, an unknown user is retried, never cleaned up without evidence. - Invite-by-email no longer falls back to the mirror outside local dev; Stripe customer email follows identity email changes seen by the standing check. - Admin sign-in lands on its deep link; deletion-sync paging can't skip or stall on same-millisecond deletions; import script arg parsing. - Cutover doc: freeze window, Stripe replay, clients disabled until deletions are reconciled against a final export. * fix(oidc): use the registered docs client and its exact post-logout URI Sets OIDC_CLIENT_ID to the client registered at auth.cubityfir.st (oidc_7369d6d5736d2bea35f1ab47). The provider matches post-logout redirect URIs byte for byte and the registration is the bare origin, so the default no longer appends a trailing slash (verified against the live provider: the bare origin is accepted, the slashed form is refused). Adds scripts/oidc-check.mjs: a dev-machine end-to-end check of the registration (real sign-in, code exchange, the worker's id_token checks, claims printed; secret read from the environment, never printed). * fix(oidc): per-attempt handoff cookie and Stripe email sync on every mirror write Each sign-in now gets its own handoff cookie (annex_handoff_<attempt>), named by a non-secret attempt id the completion page passes back, so two sign-ins finishing at once in one browser each redeem their own session. refreshMirror reads the previous email in the same batch and updates the linked Stripe customer when it changes, so whichever path writes a new address first (sign-in, standing check, invite lookup, admin) keeps receipts in step. * fix(oidc): per-sign-in login-state cookie; reconcile accounts added after the identity import The login-state cookie is now annex_oidc_<state>, so sign-ins started in two tabs before either callback don't overwrite or clear each other's state. The cutover runbook now reconciles additions as well as deletions: accounts registered on the old Annex after the identity service's import must be added there with their original ids before the clients are enabled, or their Annex data is stranded under an id nobody can sign in as. * docs(oidc): freeze old Annex sign-ups before the cutover export * fix(api): keep the deletion-sync cron constant out of the worker entry module workerd loads every named export of the main module as an entrypoint, so exporting the cron string from src/index.ts stopped annex-api from starting. Moved it to lib/identityDeletions.ts, with a test that the entry module exports only handlers and classes. * feat(admin): localhost-only dev quick-login for the admin panel POST /api/dev/quick-login on the admin worker mints an admin dev user and an admin session, gated like the api worker's (DEV_QUICK_LOGIN=true AND a localhost APP_ORIGIN), so the admin e2e suite runs without a local identity service. * test(e2e): sign in with the dev quick login instead of Annex's old forms Every suite now signs in through e2e/signIn.ts (devSignIn); the admin suite uses the admin worker's quick login. Drops the Turnstile mocks and the 2FA, change-email and change-password suites, whose features moved to auth.cubityfir.st. * test(e2e): scope the admin smoke test to this run's user and audit entry * chore(admin): use the registered auth.cubityfir.st client id for the admin panel
CubityFirst
added a commit
that referenced
this pull request
Nov 19, 2026
* feat(frontend): sign in and out through auth.cubityfir.st
/login and /register hand off to /api/auth/login (the hosted page links to
registration and returns here); /auth/complete redeems the callback's
single-use code for the session JWT, which still lives in localStorage.
Sign-out revokes the Annex session and continues to the identity
service's end-session URL. Local dev keeps the quick-login buttons.
Removed the pages and helpers that moved to auth.cubityfir.st (login,
register, check/verify email, OAuth authorize, 2FA prompts, passkeys,
pending OAuth) and the security parts of account settings (password,
email change, TOTP, passkeys, sessions, delete account); settings now
links to the identity service's account and security pages, and email
and display name are read-only. /oauth/authorize redirects to the
identity service, query string included (frontend worker and SPA).
Dropped the now-unused zxcvbn, react-qr-code, @simplewebauthn/browser and
Turnstile script.
* chore(auth): retire annex-auth's OIDC provider after the cutover
auth.cubityfir.st is now the cubityfirst-auth worker's Custom Domain.
Remove annex-auth's two auth.cubityfir.st zone routes (a deploy that kept
them would try to re-add routes on a hostname another Worker owns) and the
now-unreachable provider: /oauth/{authorize,token,userinfo,jwks},
/.well-known/openid-configuration, the /admin/oauth/clients management
handlers, OIDC_ISSUER/OIDC_AUTHORIZE_URL, RATE_LIMITER_OIDC and the
OIDC_PRIVATE_KEY secret. The scheduled sweep stays. Docs, memories and
the key/client helper scripts that described Annex as the provider are
replaced by a pointer to auth.cubityfir.st.
Touches only packages/auth, docs, memories, scripts and CLAUDE.md, so it
can be cherry-picked onto main and shipped with the next annex-auth deploy.
* feat(admin): admin panel signs in through auth.cubityfir.st; sync account deletions (#25)
* feat(admin): sign in to the admin panel through auth.cubityfir.st
The admin panel is its own first-party OIDC client (scopes openid profile
email roles; sign-in requires the admin role, re-checked live via the
identity service). It reuses the API worker's sign-in flow (now a shared
AuthFlow: login/callback/exchange/logout) with an 'admin' session kind, and
server-side OIDC requests go over the IDENTITY_OIDC service binding.
Removed what moved to auth.cubityfir.st: the docs-app handoff, the OAuth
clients tab, and account moderation (disable/suspend/re-enable, force
password change). Standing shows as read-only from the users mirror, with
a live refresh in user details and links to manage the account there.
Delayed deletion now deletes Annex data only: scheduling blocks the person
from Annex, the cron removes sites/orgs the operator confirmed, Stripe,
memberships, billing, preferences and sessions, and marks the schedule
completed. The users row and schedule stay, so they remain blocked until
the identity account is deleted on auth.cubityfir.st. All admin data now
lives in cubedocs-main; no AUTH_DB or AUTH binding.
* feat(api): sync account deletions from auth.cubityfir.st
An hourly cron polls IdentityService.listDeletedUsers from the newest
deletion already recorded in identity_deletions and removes each deleted
account's Annex data: the Stripe customer (cancelling Ink), memberships,
API keys, doc shares, favourites, avatars and the users mirror row
(cascading sessions, billing, preferences and any admin deletion).
Sites and organizations they owned are kept with their owner rows and
listed in the admin panel's Projects page for an operator to review.
Failures (e.g. Stripe) stay pending with last_error and retry hourly.
Drops cleanupDeletedAccount, which deleted owned sites and had no caller
left after DELETE /me moved to the identity service.
* chore(oidc): remove annex-auth, harden the client after review, port e2e to the new sign-in (#26)
* chore: remove packages/auth (annex-auth) now that nothing depends on it
Identity lives on auth.cubityfir.st and everything Annex-specific moved
into the api worker, so the annex-auth worker package goes: root
dev/build/deploy/typecheck/test scripts, the auth migrations step,
d1-local's "auth" database and e2e's auth-DB calls (account data is in
cubedocs-main now). The cubedocs-auth schema survives as a fixture for the
one-time import script. Admin + admin-frontend tests join the root
`pnpm test`, and `dev:stripe` forwards to the api worker.
Adds e2e/signIn.ts (dev quick-login) for porting the e2e suites, which
still drive Annex's old registration and login forms.
* docs: describe Annex as a client of auth.cubityfir.st
CLAUDE.md's auth section, schema notes, admin deletion, worker config and
local-dev notes now describe the OIDC client model: Annex sessions and the
users mirror in cubedocs-main, the IDENTITY RPC and IDENTITY_OIDC bindings
(and why same-zone fetches must use the binding), the deletion sync, and
the e2e suites that still need porting. New memories/Identity-Client.md
covers the flow, client registration and the cutover steps;
.dev.vars.example files show how to point local dev at a local identity
worker. Ink-Stripe, Api-Keys, Collab, Worktree-Dev, README and
CONTRIBUTING drop the auth worker.
* fix(oidc): harden sign-in handoff, deletion and billing paths after review
- The single-use handoff code now travels only in an HttpOnly,
SameSite=Strict cookie (never in a URL), so a crafted /auth/complete
link can't sign anyone in (login CSRF).
- A recorded or persisted identity deletion wins over the standing cache,
the mirror fallback and any in-flight mirror refresh (sessions, API
keys, collab); deleted owners' kept member rows are scrubbed.
- Admin deletion: the live admin role is required at scheduling and
re-checked before execution; the point of no return is tied to the
Stripe customer the preflight saw.
- Stripe webhook: billing upserts are guarded against tombstones; a
blocked event deletes its customer, an unknown user is retried, never
cleaned up without evidence.
- Invite-by-email no longer falls back to the mirror outside local dev;
Stripe customer email follows identity email changes seen by the
standing check.
- Admin sign-in lands on its deep link; deletion-sync paging can't skip
or stall on same-millisecond deletions; import script arg parsing.
- Cutover doc: freeze window, Stripe replay, clients disabled until
deletions are reconciled against a final export.
* fix(oidc): use the registered docs client and its exact post-logout URI
Sets OIDC_CLIENT_ID to the client registered at auth.cubityfir.st
(oidc_7369d6d5736d2bea35f1ab47). The provider matches post-logout
redirect URIs byte for byte and the registration is the bare origin, so
the default no longer appends a trailing slash (verified against the live
provider: the bare origin is accepted, the slashed form is refused).
Adds scripts/oidc-check.mjs: a dev-machine end-to-end check of the
registration (real sign-in, code exchange, the worker's id_token checks,
claims printed; secret read from the environment, never printed).
* fix(oidc): per-attempt handoff cookie and Stripe email sync on every mirror write
Each sign-in now gets its own handoff cookie (annex_handoff_<attempt>),
named by a non-secret attempt id the completion page passes back, so two
sign-ins finishing at once in one browser each redeem their own session.
refreshMirror reads the previous email in the same batch and updates the
linked Stripe customer when it changes, so whichever path writes a new
address first (sign-in, standing check, invite lookup, admin) keeps
receipts in step.
* fix(oidc): per-sign-in login-state cookie; reconcile accounts added after the identity import
The login-state cookie is now annex_oidc_<state>, so sign-ins started in
two tabs before either callback don't overwrite or clear each other's
state.
The cutover runbook now reconciles additions as well as deletions:
accounts registered on the old Annex after the identity service's import
must be added there with their original ids before the clients are
enabled, or their Annex data is stranded under an id nobody can sign in as.
* docs(oidc): freeze old Annex sign-ups before the cutover export
* fix(api): keep the deletion-sync cron constant out of the worker entry module
workerd loads every named export of the main module as an entrypoint, so
exporting the cron string from src/index.ts stopped annex-api from
starting. Moved it to lib/identityDeletions.ts, with a test that the
entry module exports only handlers and classes.
* feat(admin): localhost-only dev quick-login for the admin panel
POST /api/dev/quick-login on the admin worker mints an admin dev user and
an admin session, gated like the api worker's (DEV_QUICK_LOGIN=true AND a
localhost APP_ORIGIN), so the admin e2e suite runs without a local
identity service.
* test(e2e): sign in with the dev quick login instead of Annex's old forms
Every suite now signs in through e2e/signIn.ts (devSignIn); the admin
suite uses the admin worker's quick login. Drops the Turnstile mocks and
the 2FA, change-email and change-password suites, whose features moved to
auth.cubityfir.st.
* test(e2e): scope the admin smoke test to this run's user and audit entry
* chore(admin): use the registered auth.cubityfir.st client id for the admin panel
CubityFirst
added a commit
that referenced
this pull request
Nov 19, 2026
Annex becomes an OpenID Connect client of auth.cubityfir.st and keeps its own sessions, users mirror, billing and preferences. annex-auth and packages/auth are removed. Squashes the stack: - #23 api: OIDC client, users mirror, billing/webhook/me moved out of annex-auth - #24 frontend: sign-in/out through the provider, /oauth/authorize redirect - #25 admin: admin panel as its own client, hourly identity deletion sync - #26 annex-auth removal, review fixes, e2e port, registered admin client id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The admin panel signed in through a handoff from the docs app's annex-auth session, and accounts deleted on auth.cubityfir.st would otherwise linger in Annex.
kind = 'admin'sessions, requires theadminrole). The handoff, the OAuth-clients tab and the moderation screens are gone; moderation happens on auth.cubityfir.st.IDENTITY.listDeletedUsers): removes a deleted account's personal Annex data, memberships and Stripe customer, but keeps the sites and orgs they owned, listed on the admin Projects page ("Owner account deleted") for review.Stack (merge in order; each PR's diff is only its own commits):
mainpackages/auth, review hardening, docs, e2e portReviewed with sol-loop: 9 rounds with gpt-6.2-sol. Sol verdict: approved