-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
ansible/files/postgresql_extension_custom_scripts/pg_cron/after-create.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
grant usage on schema cron to postgres with grant option; | ||
grant all on all functions in schema cron to postgres with grant option; | ||
|
||
alter default privileges for user supabase_admin in schema cron grant all | ||
on sequences to postgres with grant option; | ||
alter default privileges for user supabase_admin in schema cron grant all | ||
on tables to postgres with grant option; | ||
alter default privileges for user supabase_admin in schema cron grant all | ||
on functions to postgres with grant option; | ||
|
||
grant all privileges on all tables in schema cron to postgres with grant option; | ||
revoke all on table cron.job from postgres; | ||
grant select on table cron.job to postgres with grant option; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
postgres-version = "15.1.0.131" | ||
postgres-version = "15.1.0.132" |
47 changes: 47 additions & 0 deletions
47
migrations/db/migrations/20231020085357_revoke_writes_on_cron_job_from_postgres.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
-- migrate:up | ||
do $$ | ||
begin | ||
if exists (select from pg_extension where extname = 'pg_cron') then | ||
revoke all on table cron.job from postgres; | ||
grant select on table cron.job to postgres with grant option; | ||
end if; | ||
end $$; | ||
|
||
CREATE OR REPLACE FUNCTION extensions.grant_pg_cron_access() RETURNS event_trigger | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
IF EXISTS ( | ||
SELECT | ||
FROM pg_event_trigger_ddl_commands() AS ev | ||
JOIN pg_extension AS ext | ||
ON ev.objid = ext.oid | ||
WHERE ext.extname = 'pg_cron' | ||
) | ||
THEN | ||
grant usage on schema cron to postgres with grant option; | ||
|
||
alter default privileges in schema cron grant all on tables to postgres with grant option; | ||
alter default privileges in schema cron grant all on functions to postgres with grant option; | ||
alter default privileges in schema cron grant all on sequences to postgres with grant option; | ||
|
||
alter default privileges for user supabase_admin in schema cron grant all | ||
on sequences to postgres with grant option; | ||
alter default privileges for user supabase_admin in schema cron grant all | ||
on tables to postgres with grant option; | ||
alter default privileges for user supabase_admin in schema cron grant all | ||
on functions to postgres with grant option; | ||
|
||
grant all privileges on all tables in schema cron to postgres with grant option; | ||
revoke all on table cron.job from postgres; | ||
grant select on table cron.job to postgres with grant option; | ||
END IF; | ||
END; | ||
$$; | ||
|
||
drop event trigger if exists issue_pg_cron_access; | ||
CREATE EVENT TRIGGER issue_pg_cron_access ON ddl_command_end | ||
WHEN TAG IN ('CREATE EXTENSION') | ||
EXECUTE FUNCTION extensions.grant_pg_cron_access(); | ||
|
||
-- migrate:down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters