Skip to content

Commit 873e63b

Browse files
committed
fix: pgsodium after-create script
1 parent 82b96e0 commit 873e63b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
do $$
2+
declare
3+
_extversion text := @extversion@;
4+
_r record;
5+
begin
6+
if _extversion is not null and _extversion != '3.1.8' then
7+
raise exception 'only pgsodium 3.1.8 is supported';
8+
end if;
9+
end $$;
10+
111
grant execute on function pgsodium.crypto_aead_det_decrypt(bytea, bytea, uuid, bytea) to service_role;
212
grant execute on function pgsodium.crypto_aead_det_encrypt(bytea, bytea, uuid, bytea) to service_role;
313
grant execute on function pgsodium.crypto_aead_det_keygen to service_role;
14+
15+
CREATE OR REPLACE FUNCTION pgsodium.mask_role(masked_role regrole, source_name text, view_name text)
16+
RETURNS void
17+
LANGUAGE plpgsql
18+
SECURITY DEFINER
19+
SET search_path TO ''
20+
AS $function$
21+
BEGIN
22+
EXECUTE format(
23+
'GRANT SELECT ON pgsodium.key TO %s',
24+
masked_role);
25+
26+
EXECUTE format(
27+
'GRANT pgsodium_keyiduser, pgsodium_keyholder TO %s',
28+
masked_role);
29+
30+
EXECUTE format(
31+
'GRANT ALL ON %I TO %s',
32+
view_name,
33+
masked_role);
34+
RETURN;
35+
END
36+
$function$;

0 commit comments

Comments
 (0)