Spaces:
Running
Running
Commit History
-
feat(admin): add platform-admin-gated routes to onboard a new university
Donne120 +1: Claude Sonnet 5Phase 3 of the multi-university platform plan. Adds the backend half of "add a university" — a data-entry action, not an engineering task, per the plan the team reviewed. - auth.py: new PLATFORM_ADMIN_EMAILS env var and require_platform_admin dependency, deliberately separate from ADMIN_EMAILS. ADMIN_EMAILS scopes "admin of one university" (an ALU staffer managing ALU's own dashboard); creating a brand new organization is a different, higher-privilege platform-operator action that must not be reachable by an ordinary university's admin. require_platform_admin also skips the org-domain check entirely (it doesn't go through require_user) — a platform operator's own email need not belong to any onboarded university, which matters for creating the very first organization on a fresh deployment. - admin_routes.py: GET/POST /admin/organizations and PATCH /admin/organizations/{id}/deactivate, all gated by require_platform_admin instead of the current_org*/ADMIN_EMAILS pat…cf9b76e -
feat(auth): resolve user's organization from Aurora instead of a hardcoded ALU allowlist
Donne120 +1: Claude Sonnet 5Phase 1 of the multi-university platform plan. require_user/require_admin now check the organizations table (via a new db.get_org_by_domain helper) instead of a fixed ALLOWED_DOMAINS tuple, so a second university's students can sign in the moment their org row exists — no code change or redeploy. The legacy ALLOWED_DOMAINS tuple is kept as a fallback ONLY for when Aurora is unreachable (the cluster auto-pauses after idle), so a transient DB hiccup can never lock out existing ALU students. It intentionally never admits a domain that wasn't already hardcoded before this change. 10 unit tests cover: new-org admission, unknown-domain rejection, the Aurora-down fallback (and its deliberate narrowness), inactive orgs, and admin gating on top of org resolution. admin_routes.py still imports cleanly (no circular import introduced). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>80c696a
-
Lock admin routes with Firebase auth; harden CORS, docs, debug
Donne120 +1: Claude Opus 4.8Server-side authorization is now the real gate for /api/admin/*: - auth.py verifies Firebase ID tokens; require_admin checks ADMIN_EMAILS, require_user enforces the ALU-email allowlist server-side. - /api/admin/sheet-status now requires an admin (was fully open). - /api/admin/refresh-sheet accepts an admin token OR the static X-Refresh-Token so the Apps Script onEdit trigger keeps working. - CORS defaults to the Vercel origin instead of "*". - /docs, /redoc, /openapi.json and /debug are off unless ENABLE_DOCS=1. Secrets (FIREBASE_SERVICE_ACCOUNT, ADMIN_EMAILS) are read only from the environment / HF Space secrets and never stored in the repo. Also refines the Claude system prompt with a Swaniker-style voice guide. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>ae1a47a