© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•7d ago•
16 replies
Ridham_Chitre

Cannot enable RLS policy for storage.buckets table

storage
I am Trying to upload files in supabase buckets. I am not using supabase AUth I have my own token creation system and user table.

Now I have setup RLS policy all the buckets as shown below

CREATE POLICY "anon can do 1x24yub_0" ON "storage"."objects" FOR INSERT TO "anon" WITH CHECK ((("bucket_id" = 'fontuploads'::"text") AND ("split_part"("name", '/'::"text", 1) = "public"."get_org_id"())));

CREATE POLICY "anon can do 1x24yub_1" ON "storage"."objects" FOR SELECT TO "anon" USING ((("bucket_id" = 'fontuploads'::"text") AND ("split_part"("name", '/'::"text", 1) = "public"."get_org_id"())));


The get_org_id() function is designed to handle the custom Header passed from the Frontend using below function

export const supabaseAuthClient = () => {
const userSession = userSessionStore();
return createClient(supabaseUrl, supabaseAnonKey, {
global: {
headers: {
'Authorization': userSession?.session?.token ? ${userSession?.session.token} : ''
}
}
});
};

Where the userSession?.session.token is my custom token.

The get_org_id function decodes the authtoken and gets org_id encoded in the token. THe token is generated with below function

def create_jwt_token(user):
payload = {
"sub":user["id"],
"app_metadata":{
"org_id":user["org_id"],
"is_active":user["is_active"],
"is_super_admin":user["is_super_admin"]

},
'exp': datetime.utcnow()+timedelta(days=30) # Token valid for 30 days
}
token = jwt.encode(payload,jwt_secret_key, algorithm='HS256')
return token
However when I try to upload image, it gives below error

{
"statusCode": "403",
"error": "Unauthorized",
"message": "signature verification failed"
}

I tried to see of the RLS policy is enabled or not for storage shcema and found out that storage.buckets has the RLS disabled.

When I tried to enable using the query

ALTER TABLE storage.buckets
ENABLE ROW LEVEL SECURITY;

it gave me below error

Error: Failed to run sql query: ERROR: 42501: must be owner of table buckets

Can anyone help me?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Cannot enable RLS on storage.objects table for my project
SupabaseSSupabase / help-and-questions
3mo ago
Enable RLS on Storage.Objects
SupabaseSSupabase / help-and-questions
4mo ago
storage buckets
SupabaseSSupabase / help-and-questions
2mo ago
Storage Buckets
SupabaseSSupabase / help-and-questions
3y ago