fix(supabase): no USAGE on schema private for anon; pin it and RPC EXECUTE in pgTAP

This commit is contained in:
bchanot committed 2026-10-08 22:47:20 +02:00
1 parent 1dd45a3109
commit 1e7d0327cc
2 files changed
+5 -2

No files matched your search

@@ -15,7 +15,8 @@ revoke all on schema private from public;
revoke all on schema audit from public;
-- Policies evaluated for API roles call private.* helpers by qualified name,
-- which needs USAGE on the schema. EXECUTE is granted per function below.
grant usage on schema private to anon, authenticated, service_role;
-- anon gets nothing: no policy for anon evaluates a helper yet.
grant usage on schema private to authenticated, service_role;
grant usage on schema audit to authenticated, service_role;
-- PostgreSQL grants EXECUTE on every new function to PUBLIC. Flip the default
+3 -1
View File
@@ -1,6 +1,6 @@
-- Schema contract: objects exist, RLS is on, API roles start from zero.
begin;
select plan(22);
select plan(24);
-- Schemas
select has_schema('private', 'schema private exists');
@@ -48,6 +48,8 @@ select ok(not has_table_privilege('authenticated', 'public.profiles', 'insert'),
select ok(not has_table_privilege('authenticated', 'public.profiles', 'delete'), 'authenticated cannot delete profiles');
select ok(not has_table_privilege('authenticated', 'public.profile_roles', 'insert'), 'authenticated cannot insert profile_roles');
select ok(not has_column_privilege('authenticated', 'public.profiles', 'active', 'update'), 'authenticated cannot update profiles.active');
select ok(not has_schema_privilege('anon', 'private', 'usage'), 'anon has no usage on schema private');
select ok(not has_function_privilege('anon', 'public.grant_platform_role(uuid, public.platform_role)', 'execute'), 'anon cannot execute grant_platform_role');
select * from finish();
rollback;