Skip to content

Commit

Permalink
[postgres] give ingest access to the encryption_keys table
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Dec 13, 2024
1 parent da404a7 commit 73f8a7c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion postgresql/initdb.d/01_main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ VALUES (0, now(), 'Created with version'),
(12, now(), 'Add key hash'),
(13, now(), 'Create API user'),
(14, now(), 'Create Auth user'),
(15, now(), 'Give API user insert priviledge in logs table');
(15, now(), 'Give API user insert priviledge in logs table'),
(16, now(), 'Give ingest user select priviledge in encryption_keys table');

-- Datasets are used to group files, and permissions are set on the dataset
-- level
Expand Down
1 change: 1 addition & 0 deletions postgresql/initdb.d/04_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ GRANT USAGE, SELECT ON SEQUENCE sda.checksums_id_seq TO ingest;
GRANT INSERT ON sda.file_event_log TO ingest;
GRANT SELECT ON sda.file_event_log TO ingest;
GRANT USAGE, SELECT ON SEQUENCE sda.file_event_log_id_seq TO ingest;
GRANT SELECT ON sda.encryption_keys TO ingest;

-- legacy schema
GRANT USAGE ON SCHEMA local_ega TO ingest;
Expand Down
21 changes: 21 additions & 0 deletions postgresql/migratedb.d/16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

DO
$$
DECLARE
-- The version we know how to do migration from, at the end of a successful migration
-- we will no longer be at this version.
sourcever INTEGER := 15;
changes VARCHAR := 'Give ingest user select priviledge in encryption_keys table';
BEGIN
IF (select max(version) from sda.dbschema_version) = sourcever then
RAISE NOTICE 'Doing migration from schema version % to %', sourcever, sourcever+1;
RAISE NOTICE 'Changes: %', changes;
INSERT INTO sda.dbschema_version VALUES(sourcever+1, now(), changes);

GRANT SELECT ON sda.encryption_keys TO ingest;

ELSE
RAISE NOTICE 'Schema migration from % to % does not apply now, skipping', sourcever, sourcever+1;
END IF;
END
$$

0 comments on commit 73f8a7c

Please sign in to comment.