The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: update access control guide
Kang Ming213f925bbd15
diff --git a/apps/docs/pages/guides/storage/access-control.mdx b/apps/docs/pages/guides/storage/access-control.mdxindex 61407692596..29427bed74f 100644--- a/apps/docs/pages/guides/storage/access-control.mdx+++ b/apps/docs/pages/guides/storage/access-control.mdx@@ -34,7 +34,27 @@ To allow read access to files, the RLS policy must allow users to `SELECT` the `Storage buckets are private by default. For private buckets, you can access objects via the [download](/docs/reference/javascript/storage-from-download) method. This corresponds to `/object/auth/` API endpoint. Alternatively, you can create a publicly shareable URL with an expiry date using the [createSignedUrl](/docs/reference/javascript/storage-from-createsignedurl) method which calls the `/object/sign/` API.-For public buckets, you can access the assets directly without a token or an Authorisation header. The [getPublicUrl](/docs/reference/javascript/storage-from-getpublicurl) helper method returns the full public URL for an asset. This calls the `/object/public/` API endpoint internally. While no authorization is required for accessing objects in a public bucket, proper [access control](#access-control) is required for other operations like uploading, deleting objects from public buckets as well. Public buckets also tend to have [better performance](/docs/guides/storage-cdn#public-vs-private-buckets).+For public buckets, you can access the assets directly without a token or an Authorisation header. The [getPublicUrl](/docs/reference/javascript/storage-from-getpublicurl) helper method returns the full public URL for an asset. This calls the `/object/public/` API endpoint internally. While no authorization is required for accessing objects in a public bucket, proper access control is required for other operations like uploading, deleting objects from public buckets as well. An easy way to get started would be to create RLS policies for `SELECT`, `INSERT`, `UPDATE`, `DELETE` operations and tightening the policies until it meets your security requirements. For example, one can start with the following `INSERT` policy:++```sql+create policy "policy_name"+ON storage.objects+for insert using (+ true+);+```++and modify it to only allow authenticated users to upload assets to a specific bucket by changing it to:++```sql+create policy "policy_name"+on storage.objects for insert to authenticated using (+ -- restrict bucket+ bucket_id = 'my_bucket_id'+);+```++Public buckets also tend to have [better performance](/docs/guides/storage-cdn#public-vs-private-buckets).The URLs to access storage endpoints are prefixed with <code>/storage/v1</code>. For example, on the hosted Platform they will be: