3.1 KiB
3.1 KiB
TASK METADATA
- Target Files:
server/routes/auth_forward.tsui/db_queries.tsui/mod.tsserver/routes/events.tsserver/tests/forward_auth.test.tsserver/tests/events.test.ts
- Core Objective: Implement Phase 1 of the Event Delegation & Ingress Overhaul: enable Traefik ForwardAuth guest ingress for scoped event attendees, bridge session custom scopes to the Launchpad UI, and wire audit logging on seat claims.
- Dependencies: None.
- Additional Important Notes:
- Strictly 100% pure Hono SSR JSX.
- Zero-Trust Ingress Rule:
account_status: 'guest'must ONLY be permitted if the session holds the specificapp:<appName>custom scope for the target host. - Must pass all quality gates (
deno fmt,deno task lint,deno task check, anddeno test --allow-all).
Architectural Considerations & Risks
Risks
- Scope Leakage: If ForwardAuth allows any guest account through without
validating the specific
app:<appName>scope, a guest for Event A could access Event B's workload.- Mitigation: In
server/routes/auth_forward.ts, explicitly require that eithergrantRoleexists in PostgreSQL orauth.customScopesincludesapp:${appRecord.name}.
- Mitigation: In
- Launchpad Scope Resolution: Guests do not have rows in the
grantstable.- Mitigation: Update
getDashboardAppsinui/db_queries.tsto accept optionalcustomScopes?: string[]fromauthand query matching apps with role'Guest (Viewer)'.
- Mitigation: Update
Proposed Implementation
1. ForwardAuth Guest Ingress (server/routes/auth_forward.ts)
- Update the user account status validation (around line 120):
- Permit
user.account_status === "active" || user.account_status === "guest".
- Permit
- Update the grant resolution check (around line 128):
- Check if
auth.customScopescontainsapp:${appRecord.name}. - If matched, set
grantRole = "viewer"(or the role defined in scopes) and allow ingress with injectedX-Forwarded-*headers.
- Check if
2. Launchpad Guest Scopes (ui/db_queries.ts & ui/mod.ts)
- Update
getDashboardApps(userId: string, isAdmin: boolean, customScopes?: string[]):- If
customScopescontains items formatted asapp:<appName>, query theappstable for those app names. - Return the app records with
role: "Guest (Viewer)".
- If
- In
ui/mod.tsunder/dashboard: Passauth.customScopestogetDashboardApps.
3. Join Audit Logging (server/routes/events.ts)
- In
POST /api/join(around line 265):- Call
auditWrapper.auditLog(guestUuid, "event_seat_claimed", event.id, { eventName: event.name, slug: event.slug, seatNumber: event.seats_claimed }, getClientIp(c)) - Ensures all guest claims are captured in the Merkle audit ledger.
- Call
4. Unit & Integration Tests
- In
server/tests/forward_auth.test.ts:- Add test:
Tier 1 & 2: GET /api/forward-auth - Guest session with app scope allowed. - Add test:
Tier 1 & 2: GET /api/forward-auth - Guest session without app scope rejected (403).
- Add test:
- In
server/tests/events.test.ts:- Verify that
POST /api/jointriggersevent_seat_claimedaudit event.
- Verify that