This folder contains an example project for demonstrating the usage of the standalone configuration tool.
The source .pol
and .env
archives are located in the src
folder of the example project. The archives are protected by the passphrase changeme
.
It is a simple API Gateway project providing an HTTPS endpoint /version
which returns a JSON with the version of the project.
$ curl -ks https://localhost:8443/version
{
"version": {
"artifact": "undefined",
"buildTime": "1970-01-01T00:00:00",
"name": "",
"description": ""
}
}
The project contains environmentalized attributes.
So the values of the artifact
and buildTime
properties can be configured.
Also the port and the host of the HTTPS endpoint is environmentalized.
📎
|
For testing, you could deploy the |
The goal of this demo is to configure the environmentalized fields for a staging environment. Also the server and CA certificates will be replaced by the certificates of the staging environment.
The passphrase for the configured .fed
archive will be changed to changed
.
To execute the demo just start the run.cmd
.
It will generate a configured gateway.fed
archive in the directory of the run.cmd
file.
If you deploy the configured archive to a gateway the API call looks similar to the following example.
📎
|
For deployment, remember to set the group passphrase via managedomain .
|
$ curl -ks https://localhost:18443/version (1)
{
"version": {
"artifact": "demo-1.0.0", (2)
"buildTime": "2019-12-16T20:38:11.080000", (3)
"name", Demo, (4)
"description": "Service for demonstration of configuration tool." (5)
}
}
-
Server and port is set to
localhost:18443
-
Artifact is replaced.
-
Build time is automatically generated.
-
Name is set.
-
Description is set.
📎
|
You can check the archives with PolicyStudio by creating a new project from the Remember to use the passphrase |
We have a set of configuration files in the config
folder:
-
gateway.config.json
: used to configure the environmentalized fields. -
gateway.certs.json
: used to replace certificates identified by their alias. -
gateway.props.json
: used for properties not applicable in the configuration or certs file. This file may be generated during the build process with values from external resources (e.g. configuration DB or secured vault). -
gateway.crypt.json
: used for confidential properties. All values in this file are encrypted.
📎
|
For a description of the configuration files please check the User Guide |
To decrypt the confidential values there is a key.binary
file.
This a file containing any arbitrary bytes.
If you edit this file with a text editor be aware of the encoding and the end of line sequence.
🔥
|
Never store the key file in the source code repository. Here it’s only for demonstration. |
In this example some environment variables (INFO_NAME
and NEW_SERVER_PASSWORD
) are set.
Then the buildfed
tool will be invoked with the following parameters:
-
-e src/gateway.env
: specifies the path to the input.env
archive -
-p src/gateway.pol
: specifies the path to the input.pol
archive -
-c config/gateway.config.json
: specifies the path to the environmentalized fields configuration file -
--cert=config/gateway.certs.json
: specifies the path to the certificates configuration file -
--prop=config/gateway.props.json
: specifies the path to a properties file -
--prop=config/passwords.props.json
: specifies the path to a second properties file -
--output-fed=gateway.fed
: specifies the path for the configured.fed
archive -
--passphrase-in=changeme
: passphrase for input archives (.pol
and.env
) -
--passphrase-out=changed
: passphrase for the generated.fed
file -
-D artifact:demo-1.0.0
: specifies the value of propertyartifact
via the command line instead of from the configuration files -
-F info.descr:config/description.txt
: specifies to set the value of propertyinfo.descr
from the content of theconfig/description.txt
file -
--secrets-file=config/gateway.crypt.json
: specifies the path to a properties file containing confidential values -
--secrets-key=key.binary
: specifies the path to the key file for decrypting the confidential values
The tool reads the source archives, configures the environmentalized fields, replaces the certificates and write the configured .fed
file.
📎
|
The value of the build time is sourced from an auto-generated, tool internal, property. |