CovidCode service is an authorization code generation service for the CovidCode-UI. | Read-only mirror of https://github.com/admin-ch/CovidCode-Service — Bundesamt für Informatik und Telekommunikation. Issues & pull requests at the source.
  • Java 99.8%
  • PLpgSQL 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Armin-Isenring-Bit 35676b7956
Merge pull request #48 from admin-ch/feature/vaccinecer-2413-deployment
Feature/vaccinecer 2413 deployment
2023-01-16 14:50:31 +01:00
.github/workflows upgrade to java 17 and required library upgrades 2022-12-20 14:42:52 +01:00
devsupport test: “out-of-BIT” development support (#14) 2020-06-12 09:53:53 +02:00
docker readme: add docker information 2020-06-03 14:12:02 +02:00
src cf-env added, hikari-db configuration changed 2023-01-16 09:18:45 +01:00
.gitignore Initial Commit 2020-05-12 09:35:08 +02:00
.travis.yml travis config 2020-05-13 08:09:50 +02:00
docker-compose.yml test: “out-of-BIT” development support (#14) 2020-06-12 09:53:53 +02:00
LICENSE Initial Commit 2020-05-12 09:35:08 +02:00
lombok.config Initial Commit 2020-05-12 09:35:08 +02:00
pom.xml cleanup 2023-01-16 09:39:04 +01:00
README.md Added Reproducible Builds Section 2020-06-24 08:18:16 +02:00

HA-AuthCode-Generation-Service (CovidCode-Service)

HA-AuthCode-Generation-Service is an authorization code generation service for the CovidCode-UI and the proximity tracing app.

Reproducible Builds

In order to have reproducible builds the io.github.zlika maven plugin is used. It replaces all timestamp with the timestamp of the last commit, and orders the entries in the JAR alphabetically. The github action then computes the sha256sum of the resulting JAR and adds the output as an build artifact.

Developer Instructions

Initial setup

Do this once:

  1. Install a JDK (tested with Oracle JDK v11 and OpenjDK 1.8.0)
  2. Install Maven
  3. Install Docker and docker-compose
  4. Check out CovidCode-UI in another directory

Development Cycle

Do this at the beginning of your session:

  1. Run
    docker-compose up -d
    docker-compose logs -f
    and wait for the logs to become quiescent
  2. Run CovidCode-UI in another window (ng serve)

To run manual tests, you can run CovidCode-Service with the local and keycloak-local Spring profiles using the following command:

mvn compile exec:java

(or the equivalent using your IDE's Maven functionality, if you require access to a debugger)

To run the test suite:

mvn verify

To perform a clean build, and run the test suite with full code coverage and upload the data to a locally-running SonarQube:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar

SonarQube results are thereafter visible at http://localhost:9000/

To tear down the development support environment (but retain its state on-disk):

docker-compose down

To wipe everything:

docker-compose down
docker volume rm covidcode_dbdata
mvn clean

Swagger-UI

Swagger-UI is running on http://localhost:8113/swagger-ui.html.

Local KeyCloak instance

If CovidCode-Service is being run as suggested above, it will perform authentication and access control against an OIDC / OAuth server running on http://localhost:8180/ (and so will CovidCode-UI in its default development configuration).

The credentials for the KeyCloak administrator are visible in docker-compose.yml in section keycloak:. Additionally, KeyCloak is automatically pre-populated with a bag-pts realm, containing a doctor account (password doctor) that enjoys access to both CovidCode-UI and CovidCode-Service.

PostgreSQL database

docker-compose runs a new PostgreSQL database on port 3113 and takes care of setting it up. The superuser credentials are in docker-compose.yml.

The "local" Spring profile should be used to run the application (see above). The other profiles run the script afterMigrate to reassign the owner of the objects.

Dockerfile

The docker file is provided only to run the application locally without DB. This configuration starts a PostgreSQL 11 on port 3113.
Docker Official Image from https://hub.docker.com/_/postgres.

JWT Generation

JWT generation uses a custom generator with library JJWT.

Lombok

Project uses Lombok. Configure your IDE with lombok plugin.

Security

The API is secured and a valid JWT should be provided. Note that these 2 values are needed

  • ctx:USER
  • the audience must be set to ha-authcodegeneration

Configuration

These parameters can be configured. You can find example values in application-local.yml.

The validity of the generated JWT:
authcodegeneration.jwt.token-validity

The issuer to set in the generated JWT:
authcodegeneration.jwt.issuer

The private key to sign the generated JWT:
authcodegeneration.jwt.privateKey

The Prometheus actuator endpoint is secured with username and password:
authcodegeneration.monitor.prometheus.user
authcodegeneration.monitor.prometheus.password

The allowed origin configuration for the authcode generation:
ha-authcode-generation-service.allowed-origin