The Patient User API is responsible for managing the patient user creation process, including user creation and activation, user scope management, email token generation, and extracting existing user profile from the Patient Health Record API (PHR) in the Consent2Share (C2S) application.
- Oracle Java JDK 8 with Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy
- Docker Engine (for building a Docker image from the project)
This is a Maven project and requires Apache Maven 3.3.3 or greater to build it. It is recommended to use the Maven Wrapper scripts provided with this project. Maven Wrapper requires an internet connection to download Maven and project dependencies for the very first build.
To build the project, navigate to the folder that contains the pom.xml
file using the terminal/command line.
- To build a JAR:
- For Windows, run
mvnw.cmd clean install
- For *nix systems, run
mvnw clean install
- For Windows, run
- To build a Docker Image (this will create an image with
bhits/patient-user:latest
tag):- For Windows, run
mvnw.cmd clean package docker:build
- For *nix systems, run
mvnw clean package docker:build
- For Windows, run
This API uses MySQL for persistence and Flyway for database migration. It requires having a database user account with Object and DDL Rights to a schema with default name patient-user
. Please see the Configure section for details about configuring the data source.
This is a Spring Boot project and serves the API via an embedded Tomcat instance, therefore there is no need for a separate application server to run this service.
- Run as a JAR file:
java -jar patient-user-x.x.x-SNAPSHOT.jar <additional program arguments>
- Run as a Docker Container:
docker run -d bhits/patient-user:latest <additional program arguments>
NOTE: In order for this API to fully function as a microservice in the Consent2Share (C2S) application, it is also required to setup the dependency microservices and support level infrastructure. Please refer to the Consent2Share Deployment Guide for instructions to setup the C2S infrastructure.
This API runs with a default configuration that is primarily targeted for the development environment. However, Spring Boot supports several methods to override the default configuration to configure the API for a certain deployment environment.
Please see the default configuration for this API as a guidance and override the specific configuration per the environment as needed. Also, please refer to Spring Boot Externalized Configuration documentation to see how Spring Boot applies the order to load the properties and Spring Boot Common Properties documentation to see the common properties used by Spring Boot.
java -jar patient-user-x.x.x-SNAPSHOT.jar --server.port=80 --spring.datasource.password=strongpassword
-
docker run -d bhits/patient-user:latest --server.port=80 --spring.datasource.password=strongpassword
-
docker run -d bhits/patient-user:latest --server.port=80 --spring.datasource.password=strongpassword
-
In a
docker-compose.yml
, this can be provided as:
version: '2'
services:
...
patient-user.c2s.com:
image: "bhits/patient-user:latest"
command: ["--server.port=80","--spring.datasource.password=strongpassword"]
...
NOTE: Please note that these additional arguments will be appended to the default ENTRYPOINT
specified in the Dockerfile
unless the ENTRYPOINT
is overridden.
For simplicity in development and testing environments, SSL is NOT enabled by default configuration. SSL can easily be enabled following the examples below:
java -jar patient-user-x.x.x-SNAPSHOT.jar --spring.profiles.active=ssl --server.ssl.key-store=/path/to/ssl_keystore.keystore --server.ssl.key-store-password=strongkeystorepassword
docker run -d -v "/path/on/dockerhost/ssl_keystore.keystore:/path/to/ssl_keystore.keystore" bhits/patient-user:latest --spring.profiles.active=ssl --server.ssl.key-store=/path/to/ssl_keystore.keystore --server.ssl.key-store-password=strongkeystorepassword
- In a
docker-compose.yml
, this can be provided as:
version: '2'
services:
...
patient-user.c2s.com:
image: "bhits/patient-user:latest"
command: ["--spring.profiles.active=ssl","--server.ssl.key-store=/path/to/ssl_keystore.keystore", "--server.ssl.key-store-password=strongkeystorepassword"]
volumes:
- /path/on/dockerhost/ssl_keystore.keystore:/path/to/ssl_keystore.keystore
...
NOTE: As seen in the examples above, /path/to/ssl_keystore.keystore
is made available to the container via a volume mounted from the Docker host running this container.
Java has a default CA Certificates Store that allows it to trust well-known certificate authorities. For development and testing purposes, one might want to trust additional self-signed certificates. In order to override the default Java CA Certificates Store in a Docker container, one can mount a custom cacerts
file over the default one in the Docker image as docker run -d -v "/path/on/dockerhost/to/custom/cacerts:/etc/ssl/certs/java/cacerts" bhits/patient-user:latest
NOTE: The cacerts
references regarding volume mapping above are files, not directories.
If you have any questions, comments, or concerns please see Consent2Share project site.
Please use GitHub Issues page to report issues.