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.
This commit is contained in:
1 parent
a2b87602b4
commit
d4e4637e7c
13 files changed
+334
-30
No files matched your search
+12
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user