Custom Roles
Learn about using custom roles with storage schema
In this guide, you will learn how to create and use custom roles with Storage to manage role-based access to objects and buckets. The same approach can be used to use custom roles with any other Supabase service.
Supabase Storage uses the same role-based access control system as any other Supabase service using RLS (Row Level Security).
Create a custom role
Let's create a custom role manager
to provide full read access to a specific bucket. For a more advanced setup, see the RBAC Guide.
Create a policy
Let's create a policy that gives full read permissions to all objects in the bucket teams
for the manager
role.
Test the policy
To impersonate the manager
role, you will need a valid JWT token with the manager
role.
You can quickly create one using the jsonwebtoken
library in Node.js.
Signing a new JWT requires your JWT_SECRET
. You must store this secret securely. Never expose it in frontend code, and do not check it into version control.
Now you can use this token to access the Storage API.