This repository was archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactoring: configuration of actuator and loggers * test: “out-of-BIT” development support (#14) * test(local): docker-compose.yml with PostgreSQL-in-a-box - PostgreSQL data is stored in a Docker persistent volume - SQL scripts are executed with superuser privileges at database creation time * test(local): add Keycloak server - Persist state into PostgreSQL - Set up suitable initdb.d script * test(local): Keycloak "bag-pts" realm definition - One client in `"clients"` whose `clientId` matches the one the Covidcode UI uses (`"ha-ui-web-client"`) - Client allows CORS from (`webOrigins`), and redirects to (`redirectURIs`) http://localhost:4200/ (the URL of the Covidcode UI while in development mode) - `"publicClient"` is set to true, meaning that the Covidcode UI doesn't need to set up a secret on its side - Create `bag-pts-allow` role and a `doctor` user (password `doctor`) as a member of the role - Ensure (via suitable `"protocolMappers"` entry) that membership in this role appears under "userroles" at the `userinfo` OIDC endpoint (as required by Covidcode UI: https://github.com/admin-ch/CovidCode-UI/blob/master/src/app/auth/oauth.service.ts#L91) - Ensure (using a second `"protocolMappers"` entry) that a `ctx` claim is set to `"USER"`, as per README.md. (On the other hand, the audience setting doesn't appear to be required anymore) * test(local): rewrite URLs on port 8180 with Træfik This lets covidcode-ui obtain its endpoints from http://localhost:8180/.well-known/openid-configuration which is its out-of-the-box behavior. * test(local): `mvn exec:java` - Add suitable stanzas to pom.xml to get the Covidcode-Service to start up using the `local` Spring profile (i.e. fake configuration and credentials found in `src/main/resources/application-local.yml`) - Prepare a database for it in PostgreSQL - Need a `haauthcodegeneration` superuser and a `haauthcodegeneration_role_full`, as both are expected by the Covidcode-Service SQL migration scripts squash! [feature] `mvn exec:java` * test: Sonarqube Persistence is done in-container with no volumes (i.e. not very persistent at all) * test(local): comments in YAML on how to increase logging * test(local): `mvn exec:java` : configure for use w/ local Keycloak - Add new Spring profile `keycloak-local` to override `jeap.security.oauth2.resourceserver.authorization-server` configuration - Apply it from `mvn exec:java` in pom.xml * docs: development lifecycle using the new docker-compose environment * test: avoid using port 8180 While using the docker-compose workflow, port 8180 is likely to be in use by the local KeyCloak. Co-authored-by: Dominique Quatravaux <dominique.quatravaux@epfl.ch> * Update version number to 1.0.0 Co-authored-by: Fabien Cerf <fabien.cerf@bit.admin.ch> Co-authored-by: domq <dominique@quatravaux.org> Co-authored-by: Dominique Quatravaux <dominique.quatravaux@epfl.ch>
- Loading branch information
1 parent
ae902a4
commit 79d0187
Showing
10 changed files
with
324 additions
and
81 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
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,7 @@ | ||
CREATE DATABASE haauthcodegeneration; | ||
CREATE USER haauthcodegeneration WITH PASSWORD 'secret'; | ||
ALTER USER haauthcodegeneration WITH SUPERUSER; | ||
GRANT ALL ON DATABASE haauthcodegeneration TO haauthcodegeneration; | ||
|
||
CREATE ROLE haauthcodegeneration_role_full; | ||
GRANT ALL ON DATABASE haauthcodegeneration TO haauthcodegeneration_role_full; |
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 @@ | ||
CREATE DATABASE keycloak; | ||
CREATE USER keycloak WITH PASSWORD 'keycloak'; | ||
GRANT ALL ON DATABASE keycloak TO keycloak; |
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,80 @@ | ||
{ | ||
"id": "BAG-PTS", | ||
"realm": "bag-pts", | ||
"enabled": true, | ||
"clients": [ | ||
{ | ||
"clientId": "ha-ui-web-client", | ||
"rootUrl": "https://www.covidcode-d.admin.ch", | ||
"adminUrl": "", | ||
"publicClient": true, | ||
"surrogateAuthRequired": false, | ||
"enabled": true, | ||
"redirectUris": [ | ||
"http://localhost:4200/*" | ||
], | ||
"webOrigins": [ | ||
"http://localhost:4200" | ||
], | ||
"protocolMappers": [ | ||
{ | ||
"id": "showRolesInUserinfoAsUserroles", | ||
"name": "Realm Mapper", | ||
"protocol": "openid-connect", | ||
"protocolMapper": "oidc-usermodel-realm-role-mapper", | ||
"consentRequired": false, | ||
"config": { | ||
"usermodel.clientRoleMapping.rolePrefix": "bag-pts-", | ||
"multivalued": "true", | ||
"userinfo.token.claim": "true", | ||
"id.token.claim": "true", | ||
"access.token.claim": "true", | ||
"claim.name": "userroles", | ||
"jsonType.label": "String" | ||
} | ||
}, | ||
{ | ||
"id": "hardcodedCtxClaim", | ||
"name": "Context Claim", | ||
"protocol": "openid-connect", | ||
"protocolMapper": "oidc-hardcoded-claim-mapper", | ||
"consentRequired": false, | ||
"config": { | ||
"userinfo.token.claim": "false", | ||
"id.token.claim": "true", | ||
"access.token.claim": "true", | ||
"claim.name": "ctx", | ||
"claim.value": "USER", | ||
"jsonType.label": "String" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"roles": { | ||
"realm": [ | ||
{ | ||
"name": "bag-pts-allow", | ||
"description": "Grant this role to users, so that they can use ha-ui", | ||
"composite": false, | ||
"clientRole": false, | ||
"containerId": "BAG-PTS", | ||
"attributes": {} | ||
} | ||
] | ||
}, | ||
"users" : [ | ||
{ | ||
"username" : "doctor", | ||
"enabled": true, | ||
"email" : "doctor@example.com", | ||
"firstName": "Doctor", | ||
"lastName": "Example", | ||
"credentials" : [ | ||
{ "type" : "password", | ||
"value" : "doctor" } | ||
], | ||
"realmRoles": [ "bag-pts-allow" ] | ||
} | ||
] | ||
} |
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,88 @@ | ||
# docker-compose.yml for developer support | ||
# | ||
# Usage: | ||
# | ||
# docker-compose up -d | ||
# | ||
# Port allocation scheme: | ||
# 3113 The PostgreSQL database | ||
# 4200 The Angular UI (not part of this project) | ||
# 8113 The covidcode back-end server (not managed by docker-compose) | ||
# 8180 The Keycloak server, exposed through Træfik with some URL rewriting | ||
# 9000 SonarQube, a source code linter and metrics renderer (e.g. for test coverage) | ||
|
||
version: "3" | ||
|
||
# To purge all state, stop all containers and say | ||
# | ||
# docker volume rm covidcode_dbdata | ||
# | ||
# This will erase the PostgreSQL database. Then start everything again | ||
volumes: | ||
dbdata: | ||
|
||
services: | ||
|
||
db: | ||
image: "postgres:11" | ||
container_name: "dp3t_postgres" | ||
ports: | ||
- "3113:5432" | ||
environment: | ||
POSTGRES_PASSWORD: secret | ||
volumes: | ||
- dbdata:/var/lib/postgresql/data | ||
- ./devsupport/keycloak/create-database-and-user.sql:/docker-entrypoint-initdb.d/create-keycloak-database-and-user.sql | ||
- ./devsupport/haauthcodegeneration/create-database-and-user.sql:/docker-entrypoint-initdb.d/create-haauthcodegeneration-database-and-user.sql | ||
|
||
keycloak: | ||
image: jboss/keycloak | ||
container_name: "keycloak" | ||
environment: | ||
# https://hub.docker.com/r/jboss/keycloak | ||
KEYCLOAK_USER: admin | ||
KEYCLOAK_PASSWORD: masterPassword | ||
DB_VENDOR: postgres | ||
DB_ADDR: db | ||
DB_DATABASE: keycloak | ||
DB_USER: keycloak | ||
DB_PASSWORD: keycloak | ||
KEYCLOAK_IMPORT: /tmp/realm-bag-pts-localhost.json | ||
volumes: | ||
- ./devsupport/keycloak/realm-bag-pts-localhost.json:/tmp/realm-bag-pts-localhost.json | ||
labels: | ||
- "traefik.enable=true" | ||
- "traefik.http.routers.keycloak.entrypoints=web" | ||
- "traefik.http.routers.keycloak.rule=PathPrefix(`/`)" # i.e. accept anything | ||
# Rewrite URLs so that e.g. | ||
# http://localhost:8180/.well-known/openid-configuration | ||
# works (as expected by ha-ui in its dev configuration): | ||
- "traefik.http.routers.keycloak.middlewares=rewrite-url-oidc" | ||
- "traefik.http.middlewares.rewrite-url-oidc.replacepathregex.regex=^/(\\.well-known/.*)$$" | ||
- "traefik.http.middlewares.rewrite-url-oidc.replacepathregex.replacement=/auth/realms/bag-pts/$$1" | ||
|
||
traefik: | ||
image: traefik:2.2.1 | ||
volumes: | ||
- "/var/run/docker.sock:/var/run/docker.sock:ro" | ||
command: | ||
- "--entrypoints.web.address=:80" | ||
## Enable docker provider | ||
- "--providers.docker=true" | ||
## Do not expose containers unless explicitly told so | ||
- "--providers.docker.exposedbydefault=false" | ||
## Uncomment the following two lines to turn on the Træfik | ||
## dashboard (handy for troubleshooting errors in the | ||
## `traefik.*` labels, above): | ||
# - "--api.dashboard=true" | ||
# - "--api.insecure=true" | ||
ports: | ||
- "8180:80" | ||
## Uncomment the following line to expose the Træfik dashboard | ||
## on port 8080: | ||
# - "8080:8080" | ||
|
||
sonarqube: | ||
image: sonarqube:community | ||
ports: | ||
- "9000:9000" |
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
Oops, something went wrong.