This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling roles also for local development & docker setup (#552)
- Loading branch information
1 parent
5bc93f3
commit b3d7ae6
Showing
18 changed files
with
123 additions
and
34 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,6 +6,15 @@ POSTGRES_DB=cwa | |
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
|
||
POSTGRES_DISTRIBUTION_USER=local_setup_distribution | ||
POSTGRES_DISTRIBUTION_PASSWORD=local_setup_distribution | ||
|
||
POSTGRES_SUBMISSION_USER=local_setup_submission | ||
POSTGRES_SUBMISSION_PASSWORD=local_setup_submission | ||
|
||
POSTGRES_FLYWAY_USER=local_setup_flyway | ||
POSTGRES_FLYWAY_PASSWORD=local_setup_flyway | ||
|
||
# Docker Compose PgAdmin settings | ||
PGADMIN_DEFAULT_EMAIL=[email protected] | ||
PGADMIN_DEFAULT_PASSWORD=password | ||
|
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
File renamed without changes.
7 changes: 0 additions & 7 deletions
7
common/persistence/src/main/resources/db/migration/h2/V1__createTables.sql
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
common/persistence/src/main/resources/db/specific/h2/V2__createPermissions.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 @@ | ||
-- no permissions on H2 necessary |
2 changes: 2 additions & 0 deletions
2
common/persistence/src/main/resources/db/specific/postgresql/V2__createPermissions.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,2 @@ | ||
GRANT SELECT, DELETE ON TABLE diagnosis_key TO "cwa_distribution"; | ||
GRANT INSERT ON TABLE diagnosis_key TO "cwa_submission"; |
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
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,5 @@ | ||
/* Creates default users for local development */ | ||
|
||
CREATE USER "local_setup_flyway" WITH INHERIT IN ROLE cwa_flyway ENCRYPTED PASSWORD 'local_setup_flyway'; | ||
CREATE USER "local_setup_submission" WITH INHERIT IN ROLE cwa_submission ENCRYPTED PASSWORD 'local_setup_submission'; | ||
CREATE USER "local_setup_distribution" WITH INHERIT IN ROLE cwa_distribution ENCRYPTED PASSWORD 'local_setup_distribution'; |
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,3 @@ | ||
/* Testdata creation requires INSERT permission - this is only active on local deployments */ | ||
/* Since the Diagnosis Key Table does not yet exist, this is a workaround to still allow inserts */ | ||
ALTER DEFAULT PRIVILEGES FOR USER local_setup_flyway IN SCHEMA public GRANT INSERT ON TABLES TO cwa_distribution; |
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,2 @@ | ||
/* Test Data profile requires insert permissions on diagnois key table */ | ||
GRANT INSERT ON diagnosis_key TO cwa_distribution; |
2 changes: 0 additions & 2 deletions
2
services/distribution/src/main/resources/application-cloud.yaml
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
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
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
2 changes: 0 additions & 2 deletions
2
services/submission/src/main/resources/application-cloud.yaml
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
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
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
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,5 @@ | ||
/* Creates CWA users */ | ||
|
||
CREATE USER "<change me>" WITH INHERIT IN ROLE cwa_flyway ENCRYPTED PASSWORD '<change me>'; | ||
CREATE USER "<change me>" WITH INHERIT IN ROLE cwa_submission ENCRYPTED PASSWORD '<change me>'; | ||
CREATE USER "<change me>" WITH INHERIT IN ROLE cwa_distribution ENCRYPTED PASSWORD '<change me>'; |
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,50 @@ | ||
/* | ||
* This SQL file needs to be executed when a new CWA database is set up. | ||
* It will create the necessary roles & restrict permissions to the CWA scope. | ||
*/ | ||
|
||
/* Revoke all default access to the database */ | ||
REVOKE ALL ON DATABASE cwa FROM PUBLIC; | ||
REVOKE USAGE ON SCHEMA public FROM PUBLIC; | ||
|
||
/* Create roles */ | ||
CREATE ROLE cwa_user | ||
NOLOGIN | ||
NOSUPERUSER | ||
NOINHERIT | ||
NOCREATEDB | ||
NOCREATEROLE | ||
NOREPLICATION; | ||
|
||
GRANT CONNECT ON DATABASE cwa TO cwa_user; | ||
GRANT USAGE ON SCHEMA public TO cwa_user; | ||
|
||
CREATE ROLE cwa_flyway | ||
NOLOGIN | ||
NOSUPERUSER | ||
INHERIT | ||
NOCREATEDB | ||
NOCREATEROLE | ||
NOREPLICATION | ||
IN ROLE cwa_user; | ||
|
||
/* Flyway user needs to have full access to schema */ | ||
GRANT CREATE ON SCHEMA public TO cwa_flyway; | ||
|
||
CREATE ROLE cwa_submission | ||
NOLOGIN | ||
NOSUPERUSER | ||
INHERIT | ||
NOCREATEDB | ||
NOCREATEROLE | ||
NOREPLICATION | ||
IN ROLE cwa_user; | ||
|
||
CREATE ROLE cwa_distribution | ||
NOLOGIN | ||
NOSUPERUSER | ||
INHERIT | ||
NOCREATEDB | ||
NOCREATEROLE | ||
NOREPLICATION | ||
IN ROLE cwa_user; |