Skip to content

Commit 968f07e

Browse files
committed
chore: test privileges of net schema
1 parent 33a2f5b commit 968f07e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
BEGIN;
2+
-- create net extension as supabase_admin
23
create extension if not exists pg_net with schema "extensions";
4+
5+
-- \ir migrations/db/init-scripts/00000000000003-post-setup.sql
6+
grant usage on schema net TO postgres, anon, authenticated, service_role;
7+
alter function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) security definer;
8+
alter function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) security definer;
9+
alter function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
10+
alter function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
11+
revoke all on function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) from public;
12+
revoke all on function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) from public;
13+
grant execute on function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO postgres, anon, authenticated, service_role;
14+
grant execute on function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO postgres, anon, authenticated, service_role;
15+
16+
-- postgres role should have access
17+
set local role postgres;
18+
select net.http_get('http://localhost', null::jsonb, null::jsonb, 100);
19+
20+
-- authenticated role should have access
21+
set local role authenticated;
22+
select net.http_get('http://localhost', null::jsonb, null::jsonb, 100);
323
ROLLBACK;

0 commit comments

Comments
 (0)