This is an API built with Spring Boot to perform CRUD operations on the gateway database.
See swagger specification for the exposed endpoints.
Follow these instructions to run the project locally and configure for kubernetes deployment
Ensure you have the following installed and configured locally:
- Java 21
- Maven 3.8.7 or newer
- Auth API running locally or in a development environment
- MongoDB Collection running locally or in an Atlas free tier
cluster
- Deploy one using the Terragrunt library
This section describes the configuration options available for the gateway API via environment variables and spring profiles
- Run the project with the
ssl
profile to enable SSL - To generate a self-signed keystore file for development purposes, run the following command in the project directory:
keytool -genkeypair -alias gateway-api -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore gateway-api.p12 -validity 3650
- Follow prompts to set the keystore password.
- Place the generated file in src/main/resources/keystore
- If you don't want to place the file in the resources folder:
- Run
base64 -e -i .\gateway-api.p12 -o gateway-api-base64.txt
to encode the keystore file for use in kubernetes secrets that will set theGATEWAY_API_SSL_KEY_STORE
to be the data in the text file you've just generated.
- Run
Caution
Setting VERIFY_HOSTNAMES to false should NOT be used in a live production environment, it should only be used when testing with self-signed SSL certificates.
Environment Variable | Description | Default Value | Required |
---|---|---|---|
MONGODB_CONNECTION_STRING | The connection string containing the username and password to connect to MongoDB | Y should start with mongodb:// | |
MONGODB_DATABASE_NAME | The name of the mongo database to connect to | Y | |
GATEWAY_API_SSL_KEY_STORE_PASSWORD | The keystore password to access the keystore | Y if using SSL profile | |
GATEWAY_API_SSL_KEY_STORE | The file path or file containing the public and private keys in PKCS12 format | classpath:keystore/gateway-api.p12 | N |
JWKS_URI | The endpoint of the Auth API to get the JWK to verify JWT tokens with | https://localhost:53655/auth/.well-known/jwks.json | N |
VERIFY_HOSTNAMES | If using self signed certificates for SSL, set this to false for non production environments only for development | true | N |
LOGGING_LEVEL | The root logging level for the project | info | N |
Follow the instructions below to get a development environment running:
- Clone the repository
- Navigate to the project directory
- Run
mvn clean install
to build and test the project - Run
mvn spring-boot:run
to start the server- Run
mvn spring-boot:run -Dspring-boot.run.profiles=ssl
to start the server with SSL enabled (requires extra configuration)
- Run
- To run the unit tests, run
mvn test
in the project directory - To run the integration tests see the Integration Tests Project
and make sure that the
@GatewayAPI
is added to the filter expression.
- Run the command from the project root to build and push a new image for both arm and amd platforms.
docker buildx build --platform linux/amd64,linux/arm64 -t <account name>/<image-name>:<image-tag> --push .
- See helm deployment to deploy the Gateway API to a kubernetes cluster.