Phase 7+8: Pretix + Sessionize interfaces
- Migration 20260825000000_interfaces.sql: external_id on contacts/ registrations/sessions (+ partial unique indexes), slots_id_seq, sync_runs audit table, and service-role-only sync_pretix_attendees / sync_sessionize_sessions RPCs (idempotent upserts). - sync-trigger Edge Function: admin-JWT or CRON_SECRET auth, pulls from Pretix/Sessionize base URLs, normalizes, calls the service-role RPCs. - interfaces/mock-api: dependency-free Node server (:54330) + fixtures so the full pipeline is testable without real tokens. - APPE Admin 'Interfaces' view: per-source + 'Sync all' triggers, result counts, recent sync runs, and QR CSV export; /functions proxy added. - Docs: new docs/backend/interfaces.md; updated README, roadmap, next-steps, schema, rls, rpcs, architecture, admin-app, and docs index.
This commit is contained in:
1 parent
22f5f1d317
commit
16f304d145
26 files changed
+1529
-80
No files matched your search
+10
-3
@@ -1,6 +1,6 @@
|
||||
# Row Level Security (RLS)
|
||||
|
||||
RLS is the security boundary. It is **enabled on all 13 tables**, and every
|
||||
RLS is the security boundary. It is **enabled on all 14 tables**, and every
|
||||
policy is scoped to the `authenticated` role. The `anon` role has `GRANT select`
|
||||
at the Postgres level, but RLS blocks it from reading anything — so an
|
||||
unauthenticated request sees no rows.
|
||||
@@ -52,6 +52,7 @@ Source of truth:
|
||||
| `feedback` | own **or** admin | — | — | — |
|
||||
| `leaderboard` | all authenticated | — | — | — |
|
||||
| `points_log` | own **or** admin | — | — | — |
|
||||
| `sync_runs` | admin only | — | — | — |
|
||||
|
||||
**"—" (no policy)** means normal users have **no direct write access** — those
|
||||
tables are written only by the `security definer` RPCs, which bypass RLS. This is
|
||||
@@ -119,6 +120,10 @@ create policy "leaderboard_select_all" on public.leaderboard for select to authe
|
||||
-- points_log: read own or admin
|
||||
create policy "points_log_select_own_or_admin" on public.points_log for select to authenticated
|
||||
using (contact_email = public.current_email() or public.is_admin());
|
||||
|
||||
-- sync_runs: admin only (interface sync audit)
|
||||
create policy "sync_runs_select_admin" on public.sync_runs for select to authenticated
|
||||
using (public.is_admin());
|
||||
```
|
||||
|
||||
## Storage — `materials` bucket
|
||||
@@ -150,9 +155,11 @@ see):
|
||||
|
||||
```sql
|
||||
grant usage on schema public to anon, authenticated, service_role;
|
||||
grant select on <all 13 tables> to anon, authenticated, service_role;
|
||||
grant insert, update, delete on <all 13 tables> to authenticated, service_role;
|
||||
grant select on <all 14 tables> to anon, authenticated, service_role;
|
||||
grant insert, update, delete on <all 14 tables> to authenticated, service_role;
|
||||
grant execute on function <all public RPCs + helpers> to authenticated;
|
||||
grant execute on function sync_pretix_attendees(jsonb), sync_sessionize_sessions(jsonb)
|
||||
to service_role; -- interface sync RPCs are service-role-only
|
||||
```
|
||||
|
||||
Note `anon` gets `select` but **no** `insert/update/delete`; `authenticated` gets
|
||||
|
||||
Reference in new issue
Block a user