© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•13mo ago
Ridge

Security Definer Functions - Custom Roles

I may be overthinking this. But I have a function that I want to allow authenticated users to be able to execute without access to the underlying table. I was able to do this with Security Definer and restricting access to all except allowing execute for authenticated users. However, from my understanding security definer functions can be a risk if not carefully handled.

However, I may need to do a few of these types of functions. That being said, the risk comes since they inherit the permissions of the owner, so could I create a custom Database Role that only has access to the underlying table and create the function under that role while revoking access to all other tables and functions and then that way if somehow I did mess something up, the worst thing they would be able to do is utilize the privileges of that particular role which is only reading data from those specific tables and not all of the permissions the superuser role has?
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RLS + Security definer ?
SupabaseSSupabase / help-and-questions
4mo ago
accessing values set in app_metadata security definer
SupabaseSSupabase / help-and-questions
4y ago
RLS 403 on Storage Upload despite valid subquery/SECURITY DEFINER
SupabaseSSupabase / help-and-questions
4w ago
Custom SMTP | Edge functions
SupabaseSSupabase / help-and-questions
13mo ago