--- id: 'storage-access-control' title: 'Storage ownership' description: 'Learn how Supabase Storage assigns an owner to each bucket and object from the JWT, and how to scope access to that owner with Row Level Security policies.' sidebar_label: 'Ownership' --- Knowing who owns a Storage object lets you write access rules scoped to that user. For how to write those rules, see [Storage access control](/docs/guides/storage/security/access-control). ## How Storage assigns an owner Storage automatically records an owner for each bucket and object, except those created with the `service_key` or in the Dashboard: - The owner is the user who created the resource, taken from the `sub` claim in the JWT. - When a user copies or moves an object, the owner of the new object is the user who initiated the operation. For details, see [Copy objects](/docs/guides/storage/management/copy-move-objects). - Storage keeps the owner in the `owner_id` column of the [Storage schema](/docs/guides/storage/schema/design). The schema also has an `owner` column, which is deprecated. Use `owner_id` instead. - A resource you create with the `service_key`, or in the Dashboard, has no owner set, so it's owned by anyone. ## Access control Ownership by itself provides no access control. To enforce it, scope access control on Storage resources to their owner. For example, you can implement a policy where only the owner of an object can delete it. To do this, check the `owner_id` field of the object and compare it with the `sub` claim of the JWT: ```sql create policy "User can delete their own objects" on storage.objects for delete to authenticated using ( owner_id = (select auth.uid()::text) ); ``` Row Level Security (RLS) policies are one way to enforce access control. You can also implement access control in your server code by following the same pattern. ## Related resources - [Storage access control](/docs/guides/storage/security/access-control): write RLS policies for Storage. - [Storage schema](/docs/guides/storage/schema/design): the tables that hold the `owner_id` column.