This commit is contained in:
hailin 2025-05-26 16:15:41 +08:00
parent 7cb1865183
commit 1600c29f44
1 changed files with 12 additions and 4 deletions

View File

@ -18,11 +18,19 @@ BEGIN
END IF;
-- Install ROLES
EXECUTE 'CREATE ROLE ' || anon_role || ' NOLOGIN NOINHERIT';
EXECUTE 'CREATE ROLE ' || authenticated_role || ' NOLOGIN NOINHERIT';
EXECUTE 'CREATE ROLE ' || service_role || ' NOLOGIN NOINHERIT bypassrls';
EXECUTE 'CREATE ROLE IF NOT EXISTS ' || anon_role || ' NOLOGIN NOINHERIT';
EXECUTE 'CREATE ROLE IF NOT EXISTS ' || authenticated_role || ' NOLOGIN NOINHERIT';
EXECUTE 'CREATE ROLE IF NOT EXISTS ' || service_role || ' NOLOGIN NOINHERIT bypassrls';
-- create user authenticator noinherit;
IF NOT EXISTS (
SELECT 1
FROM pg_roles
WHERE rolname = 'authenticator'
) THEN
EXECUTE 'create user authenticator noinherit;';
END IF;
create user authenticator noinherit;
EXECUTE 'grant ' || anon_role || ' to authenticator';
EXECUTE 'grant ' || authenticated_role || ' to authenticator';
EXECUTE 'grant ' || service_role || ' to authenticator';