feat(admin): build admin app foundation

未关闭
#1,956 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
github-actions, react, vite

调研方向

Start with the linked design spec, then inspect apps/web, packages/api, packages/auth-shell, and the planned apps/admin workspace. Run the existing project tests before implementing the listed policy, audit, API, frontend, deployment, and workflow requirements. Done means the checklist is complete and the policy, audit integration, and sign-in smoke tests pass.

由索引模型根据 Issue 内容生成。

描述

Summary

Establish the foundation for admin.us-rse.org — workspace, auth posture, role/permission model, audit infrastructure, and frontend shell that every later admin subsystem inherits without rework. Spec lives at docs/superpowers/specs/2026-05-09-admin-app-foundation-design.md.

Requirements

  • Extract packages/auth-shell from apps/web (AuthKit provider, env-check guard, root error boundary, useApi fetch wrapper). Public app continues to work unchanged.
  • Schema: add staff to user_role enum, backfill WHERE role = 'admin', deprecate admin in a follow-up rev.
  • packages/api/src/lib/policies/ directory with canEnterAdminApp, canApproveVocab, canMergeUsers, canEditGroup, canEditEvent, canViewAuditLog + Vitest tests.
  • requireActorContext middleware: walk merge chain to canonical user, load leadership terms + chair memberships, populate c.var.actor. Returns 403 if canEnterAdminApp fails.
  • requirePolicy(policy, scopeFn) middleware factory. Mount admin entry gate on the /api/admin/* sub-app.
  • auditMiddleware afterware: write one audit_log row per mutating admin request. Handlers enrich payload via c.var.auditPayload and c.var.auditCapture(prior).
  • GET /api/admin/me — returns { user, systemTier, positions: { leadership, chairedGroups, chairedEvents } }.
  • GET /api/admin/audit — cursor-paginated audit reader, filterable by actor / action / targetType / targetId / date range, super_admin only.
  • apps/admin workspace: Vite + React 19 + React Router 7 + design-system tokens. Mirrors apps/web patterns. Vite dev proxy /api → :8787.
  • Admin shell: sidebar (numbered nav, adaptive per useNavSections()), top bar, dashboard tiles, audit page, stub routes for every future subsystem.
  • Cloudflare Pages project us-rse-admin with admin.us-rse.org custom domain + _redirects for /api/* and SPA fallback.
  • .github/workflows/deploy-admin.yml with path filters on apps/admin/**, packages/auth-shell/**, packages/design-system/**.
  • WorkOS redirect URIs registered for admin.us-rse.org/auth/callback + preview pattern.
  • Foundation tests: policy unit tests, audit middleware integration test, one end-to-end sign-in smoke.

Context

Spec was the result of a /superpowers:brainstorming session that decomposed the broader admin-app idea into a foundation plus ten follow-up subsystems. The foundation is intentionally feature-light — it ships the cross-cutting infrastructure so each subsystem (members, vocab, organizations, groups, events, recognition, forms, elections, communications, operations) lands on a stable target.

Implementation Notes

  • Same WorkOS project for both SPAs; admin gate is a role check, not an auth-system check.
  • Same Worker for both /api/* and /api/admin/*; sub-app pattern keeps the boundary obvious in code reviews.
  • Code-defined policies, not data-defined. Auth changes are PR-reviewed and shipped.
  • Audit middleware captures every mutating request automatically; handlers can opt into before/after diffs for irreversible-feeling actions.
主要语言
HTML
星标
33
派生
107
平均合并
14 小时 6 分钟
30 天内合并 PR
19

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

USRSE/usrse.github.io 的其他 Issue

查看 USRSE/usrse.github.io 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。