Skip to content

Commit 8b9e218

Browse files
committed
fix: pgsodium after-create script
1 parent 22d1c60 commit 8b9e218

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
grant execute on function pgsodium.crypto_aead_det_decrypt(bytea, bytea, uuid, bytea) to service_role;
22
grant execute on function pgsodium.crypto_aead_det_encrypt(bytea, bytea, uuid, bytea) to service_role;
33
grant execute on function pgsodium.crypto_aead_det_keygen to service_role;
4+
5+
CREATE OR REPLACE FUNCTION pgsodium.mask_role(masked_role regrole, source_name text, view_name text)
6+
RETURNS void
7+
LANGUAGE plpgsql
8+
SECURITY DEFINER
9+
SET search_path TO ''
10+
AS $function$
11+
BEGIN
12+
EXECUTE format(
13+
'GRANT SELECT ON pgsodium.key TO %s',
14+
masked_role);
15+
16+
EXECUTE format(
17+
'GRANT pgsodium_keyiduser, pgsodium_keyholder TO %s',
18+
masked_role);
19+
20+
EXECUTE format(
21+
'GRANT ALL ON %I TO %s',
22+
view_name,
23+
masked_role);
24+
RETURN;
25+
END
26+
$function$;

0 commit comments

Comments
 (0)