You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EES-5329 Replace role public_data_admin with public_data_read_write. Configure role privileges in Postgres init script for local environment and in database migration for non-local environment.
* Grant the other application user roles privileges to look up objects on the public schema.
20
-
* Additional privileges are granted to these application user roles by the initial migration.
21
20
*/
22
21
GRANT USAGE ON SCHEMA public TO app_public_data_processor;
23
22
GRANT USAGE ON SCHEMA public TO app_admin;
24
23
GRANT USAGE ON SCHEMA public TO app_publisher;
25
24
26
25
/*
27
-
* Create an admin group role which can be granted to user roles requiring privileges on public schema objects.
28
-
* Privileges are granted to this admin group role by the initial migration.
26
+
* Create a public_data_read_write group role which can be granted to user roles requiring read and write privileges on public schema objects.
29
27
*/
30
-
CREATE ROLE public_data_admin WITH NOLOGIN;
28
+
CREATE ROLE public_data_read_write WITH NOLOGIN;
29
+
30
+
/*
31
+
* Grant privileges to the public_data_read_write group role for all tables and sequences in the public schema subsequently created by app_public_data_api.
32
+
*/
33
+
ALTER DEFAULT PRIVILEGES FOR ROLE app_public_data_api IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES ON TABLES TO public_data_read_write;
34
+
ALTER DEFAULT PRIVILEGES FOR ROLE app_public_data_api IN SCHEMA public GRANT SELECT, UPDATE ON SEQUENCES TO public_data_read_write;
35
+
36
+
/*
37
+
* Grant membership of the public_data_read_write group role to the application user roles.
38
+
*/
39
+
GRANT public_data_read_write TO app_public_data_api;
40
+
GRANT public_data_read_write TO app_public_data_processor;
Copy file name to clipboardexpand all lines: src/GovUk.Education.ExploreEducationStatistics.Public.Data.Model/Migrations/20240501113006_InitialMigration.cs
// Grant privileges to the 'public_data_read_write' group role for objects in the public schema
22
+
// subsequently created by this applications user role. Membership of the role will be granted to other
23
+
// application and indvidual user roles who require read and write privileges on public schema objects.
24
+
migrationBuilder.Sql(
25
+
$"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES ON TABLES TO {PublicDataDbContext.PublicDataReadWriteRole}");
26
+
migrationBuilder.Sql(
27
+
$"ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE ON SEQUENCES TO {PublicDataDbContext.PublicDataReadWriteRole}");
0 commit comments