© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•5mo ago•
5 replies
NagartHUN

How to Protect Base Tables with Views? (view, security_invoker, authenticated user)

Hi guys. I'm a making a FlutterFlow app and use Supabase as backend. I'm not sure how to best protect my base tables and some of the columns. Here's my setup:
- Users have to log into the app, so I guess only authenticated users are at play.
- I have, for example, a reviews table with RLS policies (all tables have policies), for reviews table authenticated users can SELECT, INSERT, UPDATE, DELETE, but only their own rows as I use (( SELECT auth.uid() AS uid) = user_id) / (auth.uid() = user_id). I don't know what's the difference.
- I created a reviews_view as suggested by the Supabase AI with security_invoker = on and I was also suggested to REVOKE SELECT on the base table FROM public, anon, authenticated; and GRANT SELECT on the new view TO authenticated. However, when I REVOKE SELECT on base table FROM authenticated, I can't load data. From what I have gathered, it's because security_invoker = on does it from the point of view of the caller, and the authenticated user does not have SELECT on the base table to load anything.
- Then suggestions were to either 1) use security_barrier, security_invoker = off so it's done from view owner perspective (supabase admin) and it can be OK if RLS policies are correct. Is that true? or 2) write some helper function and the view should use the helper function to gather the data and then I have to restrict execute or something on the function (this is more complicated for me).

I currently have 1) in use while developing, but Supabase shows a red text "Unrestricted" (Data is publicly accessible via API as this is a Security definer view.), but does having RLS policies and REVOKE INSERT FROM public, anon, authenticated actually protects the data?

Could you help me out here, what is the set up to make sure the base data with all the records are not accessible, but only a view I create (occassionally only the rows readable where the user_id = authenticated user's ID).

Many many thanks in advance!
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

Invoker on view not working
SupabaseSSupabase / help-and-questions
6mo ago
Max_stack_depth exceeded with RLS and SECURITY INVOKER view for public listings
SupabaseSSupabase / help-and-questions
8mo ago
Supabase table editor internal errors after AI assistant security invoker revert on a view
SupabaseSSupabase / help-and-questions
4mo ago
User not authenticated ERROR
SupabaseSSupabase / help-and-questions
2mo ago