Skip to content

Commit 0924609

Browse files
committed
fix: enable RLS for buckets table
1 parent 6b94a74 commit 0924609

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE storage.buckets ENABLE ROW LEVEL SECURITY;

src/test/db/02-storage-schema.sql

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ CREATE UNIQUE INDEX "bucketid_objname" ON "storage"."objects" USING BTREE ("buck
3535
CREATE INDEX name_prefix_search ON storage.objects(name text_pattern_ops);
3636

3737
ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;
38-
-- @todo enable RLS only for buckets table
3938

4039
CREATE OR REPLACE FUNCTION storage.foldername(name text)
4140
RETURNS text[]

src/test/db/03-dummy-data.sql

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ INSERT INTO "storage"."objects" ("id", "bucket_id", "name", "owner", "created_at
3636
('D3EB488E-94F4-46CD-86D3-242C13B95BAC', 'bucket3', 'sadcat-upload2.png', '317eadce-631a-4429-a0bb-f19a7a517b4a', '2021-03-01 08:53:29.567975+00', '2021-03-01 08:53:29.567975+00', '2021-03-01 08:53:29.567975+00', '{"mimetype": "image/svg+xml", "size": 1234}');
3737

3838
-- add policies
39+
-- allows user to CRUD all buckets
40+
CREATE POLICY crud_buckets ON storage.buckets for all USING (auth.uid() = '317eadce-631a-4429-a0bb-f19a7a517b4a');
3941
-- allow public CRUD acccess to the public folder in bucket2
4042
CREATE POLICY crud_public_folder ON storage.objects for all USING (bucket_id='bucket2' and (storage.foldername(name))[1] = 'public');
4143
-- allow public CRUD acccess to a particular file in bucket2

0 commit comments

Comments
 (0)