Skip to content

Admin: storage rules for the image buckets #205

Closed

Description

@Flapjacck

Photos live in two public buckets, events-images and team-images. Anyone can view them (that's what the site needs), but there are no upload policies yet, so uploads only work from the Supabase dashboard.

To do (migration in supabase/migrations/)

  • Policies on storage.objects for both buckets: insert, update and delete only when is_admin().
  • Leave public viewing as it is.

Good to know

  • The tables store the full public URL, for example https://<project>.supabase.co/storage/v1/object/public/events-images/<file>. Keep it that way so the live site keeps working.
  • Team photos are currently named by a uuid. Event photos use the original file name. Going forward, prefer <uuid>.<ext> for both so names never clash.

Done when

  • An admin can upload, replace and delete a file in both buckets from the app
  • A non-admin or signed-out user gets an error trying the same
  • Existing images still load on the live site

Activity

  1. added
    admin
    backend
    phase 1
    on Nov 18, 2026
  2. self-assigned this
    on Nov 19, 2026
  3. Flapjacck commented on Nov 19, 2026

    @Flapjacck
    MemberAuthor

    Closing as done. This was implemented in #224, which added supabase/migrations/20261119100000_admin_image_uploads.sql. The migration was applied to the live LCS-Site project on 2026-11-19.

    What's live now on storage.objects for events-images and team-images:

    • Upload, replace and delete: only when public.is_admin() is true. Signed-out and non-admin users are refused by the database itself.
    • Read through the API: admins only. This is needed so the storage API can replace (upsert) and delete files.
    • Public viewing: unchanged. Both buckets are still public, so every existing photo URL on lauriercs.org keeps loading (11 event and 28 team images).

    There were no other storage policies before this. The old temporary upload rules had already been dropped, so nothing broader overrides these.

    The "an admin can upload from the app" check gets tested for real in #211 and #214, when the upload UI lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

adminbackendphase 1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions