Skip to content

Commit 8372c18

Browse files
authored
fix(tests): grant API access to integration test tables and functions (#1018)
New Supabase behavior no longer auto-grants public schema access to the anon and authenticated roles. Explicit GRANT statements are now required for tables, views, sequences, and functions to be reachable via the REST/GraphQL Data API. Adds a new migration that grants ALL on tables, SELECT on the updatable view, USAGE/SELECT on SERIAL sequences, and EXECUTE on RPC functions to the anon and authenticated roles. Ref: https://github.com/orgs/supabase/discussions/45329
1 parent 92d7c6f commit 8372c18

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Grant API access to tables for anon and authenticated roles.
2+
-- Required since Supabase no longer grants public schema access by default
3+
-- (see https://github.com/orgs/supabase/discussions/45329).
4+
GRANT ALL ON TABLE public.users TO anon, authenticated;
5+
GRANT ALL ON TABLE public.todos TO anon, authenticated;
6+
GRANT ALL ON TABLE public.messages TO anon, authenticated;
7+
GRANT ALL ON TABLE public.channels TO anon, authenticated;
8+
GRANT ALL ON TABLE public.key_value_storage TO anon, authenticated;
9+
10+
-- Grant SELECT on updatable view
11+
GRANT SELECT ON public.updatable_view TO anon, authenticated;
12+
13+
-- Grant sequence usage for SERIAL primary key columns
14+
GRANT USAGE, SELECT ON SEQUENCE public.channels_id_seq TO anon, authenticated;
15+
GRANT USAGE, SELECT ON SEQUENCE public.messages_id_seq TO anon, authenticated;
16+
17+
-- Grant EXECUTE on RPC functions
18+
GRANT EXECUTE ON FUNCTION public.get_status(TEXT) TO anon, authenticated;
19+
GRANT EXECUTE ON FUNCTION public.void_func() TO anon, authenticated;
20+
GRANT EXECUTE ON FUNCTION public.delete_user() TO anon, authenticated;
21+
GRANT EXECUTE ON FUNCTION public.get_username_and_status(TEXT) TO anon, authenticated;
22+
GRANT EXECUTE ON FUNCTION public.get_array_element(INT[], INT) TO anon, authenticated;

0 commit comments

Comments
 (0)