feat(sessions): material downloads unlock when the session ends

Private materials bucket + RLS read gate (admins/own speakers anytime, all
attendees after the scheduled slot end, event-local Amsterdam time); always
visible uploaded-state, locked download panel, authenticated client downloads,
admin signed URLs. 12 new assertions in material_time_lock_tests.sql.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-21 18:57:15 +02:00
1 parent 7776145a77
commit a8f3f5b8e1
13 files changed
+334 -30

No files matched your search

+12 -2
View File
@@ -123,12 +123,15 @@ create policy "points_log_select_own_or_admin" on public.points_log for select t
## Storage — `materials` bucket
The `materials` bucket (public read) stores session material. Policies on
The `materials` bucket is **private** and stores session material. Downloads
unlock when the session's scheduled end has passed (event-local Amsterdam
time) — until then only the session's own speakers and admins can read the
object, so a known path/URL does not release the bytes early. Policies on
`storage.objects`:
```sql
create policy "materials_read" on storage.objects for select to authenticated
using (bucket_id = 'materials');
using (public.can_read_session_material(bucket_id, name));
create policy "materials_write" on storage.objects for insert to authenticated
with check (bucket_id = 'materials' and public.can_write_session_material(name));
create policy "materials_update" on storage.objects for update to authenticated
@@ -138,6 +141,13 @@ create policy "materials_delete" on storage.objects for delete to authenticated
using (bucket_id = 'materials' and public.can_write_session_material(name));
```
`can_read_session_material` (security definer, `20261021180000_material_time_lock.sql`)
parses `sessions/<uuid>/<file>` paths, allows `is_admin()` and
`owns_speaker_session(uuid)` at any time, everyone else only once
`session_material_unlocked(uuid)` holds (slot `slot_date + end_time <=
timezone('Europe/Amsterdam', now())`). Anything malformed or in another bucket
is denied by this policy (other buckets keep their own policies).
Registered speakers can write only their own non-service session paths; admins
retain material management access. Any authenticated attendee can read (download).
Because the `sessions` table is admin-write only, a speaker attaches their
+7 -4
View File
@@ -366,7 +366,10 @@ enqueuing, claiming, completing and dead-lettering all go through the RPCs in
## Storage
A **`materials`** bucket (public read) stores session material. Speakers + admins
can write (see [rls.md](./rls.md#storage--materials-bucket)). A session's
`material_path` points at the object; the public URL is
`/storage/v1/object/public/materials/{material_path}`.
A **`materials`** bucket (**private** since `20261021180000_material_time_lock.sql`)
stores session material. Speakers + admins can write (see
[rls.md](./rls.md#storage--materials-bucket)). A session's `material_path`
points at the object. Files are fetched through **authenticated** storage
requests (attendee app) or short-lived signed URLs (admin app); the read policy
releases a file to plain attendees only after the session's scheduled end —
`/storage/v1/object/public/...` URLs no longer serve materials.