Skip to content

Commit ce0e79e

Browse files
committed
ID-39: use key file instead of passphrase
1 parent 283c209 commit ce0e79e

File tree

15 files changed

+100
-71
lines changed

15 files changed

+100
-71
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ Use the `--base-dir` parameter of the configuration tool or the `axway.config.ce
1515
|Support for confidential properties.
1616

1717
For confidential properties the configuration tools supports to pass a secrets file.
18-
It is a JSON file where the values of the properties are encrypted by a passphrase.
19-
18+
It is a JSON file where the values of the properties are encrypted by a key.
2019
|===
2120

2221
== Version 0.12.0

doc/manual/_config-tool.adoc

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ Options:
6161
--secrets-file=FILEPATH
6262
Path of JSON file containing confidential propertiers
6363
[optional]
64-
--secrets-passphrase=PASSPHRASE
65-
Passphrase to decrypt confidential properties [optional]
64+
--secrets-key=FILEPATH
65+
Path to key file to decrypt confidential properties [optional]
6666
....
6767

6868
If environmentalized fields or certificates are not configured, the build fails.
@@ -160,10 +160,15 @@ If specified relative path to certificate files is based on this directory.
160160
|Path of JSON file containing confidential properties.
161161
The file has to be created by the `encrypt` tool.
162162

163-
|--secrets-passphrase
164-
|Passphrase to decryt confidential properties.
165-
This parameter is requried if a secrets file is specified.
166-
The passphrase has to be the same as on creating the secrets file.
163+
|--secrets-key
164+
|Path to key file to decrypt confidential properties.
165+
166+
This a file containing any arbitrary bytes.
167+
If you edit this file with a text editor be aware of the encoding and the end of line sequence.
168+
169+
The key file has to be the same as on creating the secrets file.
170+
171+
This parameter is required if a secrets file is specified.
167172
|===
168173

169174

@@ -172,7 +177,7 @@ The passphrase has to be the same as on creating the secrets file.
172177
The `encrypt` tools is used to generate an initial secrets file and to encrypt the values of the properties.
173178
The script is invoked with the `jython` interpreter provided with the package and deployment tools of the API Gateway.
174179

175-
The tool requries a path to the secrets file and a passphrase to encryt the values.
180+
The tool requires a path to the secrets file and a passphrase to encrypt the values.
176181
If the secrets file doesn't exist a new file will be created.
177182
For existing files the given passphrase is checked against the passphrase used on file creation.
178183

@@ -186,8 +191,8 @@ Options:
186191
-v, --verbose Enable verbose messages [optional]
187192
--secrets-file=FILEPATH
188193
Path of JSON file containing confidential properties
189-
--secrets-passphrase=PASSPHRASE
190-
Passphrase to decrypt confidential values
194+
--secrets-key=FILEPATH
195+
Path to key file to decrypt confidential properties
191196
192197
Encrypt credentials.
193198
....
@@ -200,9 +205,15 @@ Encrypt credentials.
200205
|--secrets-file
201206
|Path of JSON file containing confidential properties.
202207

203-
|--secrets-passphrase
204-
|Passphrase to decrypt confidential properties.
205-
This parameter is requried if a secrets file is specified.
208+
|--secrets-key
209+
|Path to key file to decrypt confidential properties.
210+
211+
This a file containing any arbitrary bytes.
212+
213+
If you edit this file with a text editor be aware of the encoding and the end of line sequence.
214+
In this case use ASCII characters in a single line (no line feed at the end).
215+
216+
This parameter is required if a secrets file is specified.
206217
|===
207218

208219
To add new properties tag the values with the `encrypt:` prefix.
@@ -218,11 +229,11 @@ Values having this prefix will be encrypted on running the tool.
218229
}
219230
}
220231
----
221-
<1> Marker to check the passphrase. Don't delete or change it.
232+
<1> Marker to check the key. Don't delete or change it.
222233
<2> The prefix `encrypt:` indicates that the value `changeme` has to be encrypted.
223234
<3> Values without the prefix are already encrypted and will not be changed.
224235

225-
NOTE: The `encrypt` tool use the cipher of the entity store.
236+
NOTE: The `encrypt` tool use the same cipher as the entity store.
226237

227238
== Configuration Files
228239

@@ -507,8 +518,8 @@ For the build process the property file may be temporarily generated from the co
507518
=== Secrets
508519

509520
A secrets file is used to store confidential configurations (e.g. passwords).
510-
The values of the properties are encrypted and can be access with a passphrase only.
511-
All values are encrypted with the same passphrase.
521+
The values of the properties are encrypted and can be access with a key only.
522+
All values are encrypted with the same key.
512523

513524
.gateway.crypt.json
514525
[source,json]
@@ -522,6 +533,6 @@ All values are encrypted with the same passphrase.
522533
}
523534
----
524535
<1> The `secrets` property is requried.
525-
<2> Marker to check the passphrase. Don't delete or change it.
536+
<2> Marker to check the key. Don't delete or change it.
526537
<3> The prefix `encrypt:` indicates that the value `changeme` has to be encrypted by the `encrypt` tool.
527538
<4> Values without the prefix are already encrypted.

doc/manual/_reference.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ NOTE: It is not checked if the source files are newer than the target artifact.
376376
|axway.config.secrets.file
377377
|Path to file storing secrets.
378378

379-
|axway.config.secrets.passphrase
380-
|Passphrase to decrypt/encrypt values of secrets file.
379+
|axway.config.secrets.key
380+
|Path to key file to decrypt/encrypt values of secrets file.
381381
|===
382382

383383
== Plugin Configuration
@@ -408,7 +408,7 @@ The plugin can also be configured in the `pom.xml` via the <configuration> eleme
408408
<configCertsBaseDir>${basedir}/src/main/axwgw/certs</configCertsBaseDir> <!--5-->
409409
410410
<configSecretsFile>${basedir}/src/main/axwgw/gateway.crypt.json</configSecretsFile> <!--6-->
411-
<configSecretsPassphrase>changeme</configSecretsPassphrase> <!--7-->
411+
<configSecretsKey>${user.home}/secrets.key</configSecretsKey> <!--7-->
412412
</configuration>
413413
</plugin>
414414
<!- ... ->
@@ -419,4 +419,4 @@ The plugin can also be configured in the `pom.xml` via the <configuration> eleme
419419
<4> Location of a list of configuration files for properties.
420420
<5> Base directory for certificate files.
421421
<6> Path to secrets file.
422-
<7> Passphrase to decrypt/encrypt values of secrets file.
422+
<7> Key file to decrypt/encrypt values of secrets file.

example/config-tool/README.adoc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,29 @@ Remember to use the passphrase `changeme` for the `.pol`and `.env` archive and t
9191

9292
== How does it work?
9393

94-
We have three configuration files in the `config` folder:
94+
We have a set of configuration files in the `config` folder:
9595

9696
* `gateway.config.json`: used to configure the environmentalized fields.
9797
* `gateway.certs.json`: used to replace certificates identified by their alias.
9898
* `gateway.props.json`: used for properties not applicable in the configuration or certs file.
9999
This file may be generated during the build process with values from external resources (e.g. configuration DB or secured vault).
100+
* `gateway.crypt.json`: used for confidential properties.
101+
All values in this file are encrypted.
100102

101103
NOTE: For a description of the configuration files please check the link:../../doc/manual/user-guide.adoc[User Guide]
102104

105+
To decrypt the confidential values there is a `key.binary` file.
106+
This a file containing any arbitrary bytes.
107+
If you edit this file with a text editor be aware of the encoding and the end of line sequence.
108+
109+
CAUTION: Never store the key file in the source code repository. Here it's only for demonstration.
110+
103111
In this example some environment variables (`INFO_NAME` and `NEW_SERVER_PASSWORD`) are set.
104112
Then the `buildfed` tool will be invoked with the following parameters:
105113

106-
* `-e src\gateway.env`: specifies the path to the input `.env` archive
107-
* `-p src\gateway.pol`: specifies the path to the input `.pol` archive
108-
* `-c config\gateway.config.json`: specifies the path to the environmentalized fields configuration file
114+
* `-e src/gateway.env`: specifies the path to the input `.env` archive
115+
* `-p src/gateway.pol`: specifies the path to the input `.pol` archive
116+
* `-c config/gateway.config.json`: specifies the path to the environmentalized fields configuration file
109117
* `--cert=config/gateway.certs.json`: specifies the path to the certificates configuration file
110118
* `--prop=config/gateway.props.json`: specifies the path to a properties file
111119
* `--prop=config/passwords.props.json`: specifies the path to a second properties file
@@ -114,6 +122,8 @@ Then the `buildfed` tool will be invoked with the following parameters:
114122
* `--passphrase-out=changed`: passphrase for the generated `.fed` file
115123
* `-D artifact:demo-1.0.0`: specifies the value of property `artifact` via the command line instead of from the configuration files
116124
* `-F info.descr:config/description.txt`: specifies to set the value of property `info.descr` from the content of the `config/description.txt` file
125+
* `--secrets-file=config/gateway.crypt.json`: specifies the path to a properties file containing confidential values
126+
* `--secrets-key=key.binary`: specifies the path to the key file for decrypting the confidential values
117127

118128
The tool reads the source archives, configures the environmentalized fields, replaces the certificates and write the configured `.fed` file.
119129

example/config-tool/encrypt.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ SET CMD_HOME=%~dp0
44
CD /d "%CMD_HOME%"
55
SET ENCRYPT="..\..\src\main\resources\scripts\encrypt.cmd"
66

7-
CALL %ENCRYPT% --secrets-file=config/gateway.crypt.json --secrets-passphrase=changeme
7+
CALL %ENCRYPT% --secrets-file=config/gateway.crypt.json --secrets-key=key.binary
88
ENDLOCAL

example/config-tool/key.binary

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
changeme

example/config-tool/run.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ REM Define environment variables for field value and password configuration
88
SET INFO_NAME=Demo
99
SET NEW_SERVER_PASSWORD=changeme
1010

11-
CALL %BUILDFED% -v -e src\gateway.env -p src\gateway.pol -c config\gateway.config.json --cert=config\gateway.certs.json --prop=config\gateway.props.json --secrets-file=config\gateway.crypt.json --secrets-passphrase=changeme -D artifact:demo-1.0.0 -F info.descr:config\description.txt --output-fed=gateway.fed --passphrase-in=changeme --passphrase-out=changed --base-dir=config/certs
11+
CALL %BUILDFED% -v -e src\gateway.env -p src\gateway.pol -c config\gateway.config.json --cert=config\gateway.certs.json --prop=config\gateway.props.json --secrets-file=config\gateway.crypt.json --secrets-key=key.binary -D artifact:demo-1.0.0 -F info.descr:config\description.txt --output-fed=gateway.fed --passphrase-in=changeme --passphrase-out=changed --base-dir=config/certs
1212
ENDLOCAL

src/main/java/com/axway/maven/apigw/AbstractGatewayMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public abstract class AbstractGatewayMojo extends AbstractMojo {
107107
@Parameter(property = "axway.config.secrets.file", required = false)
108108
protected File configSecretsFile = null;
109109

110-
@Parameter(property = "axway.config.secrets.passphrase", required = false)
111-
protected String configSecretsPassphrase = null;
110+
@Parameter(property = "axway.config.secrets.key", required = false)
111+
protected File configSecretsKey = null;
112112

113113

114114
@Parameter(defaultValue = "${project}", readonly = true)

src/main/java/com/axway/maven/apigw/DeploymentArchiveMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ private void buildFedArchive(File targetDir, File srcPolFile, File srcEnvFile, F
170170
fedBuilder.setCertificatesBasePath(this.configCertsBaseDir);
171171
}
172172
if (this.configSecretsFile != null) {
173-
if (this.configSecretsPassphrase == null)
173+
if (this.configSecretsKey == null)
174174
throw new MojoExecutionException("Passphrase for secrets file not specified!");
175-
fedBuilder.setSecrets(this.configSecretsFile, this.configSecretsPassphrase);
175+
fedBuilder.setSecrets(this.configSecretsFile, this.configSecretsKey);
176176
}
177177

178178
fedBuilder.setPassphrasePol(this.passphrasePol);

src/main/java/com/axway/maven/apigw/DeploymentMojo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ private File configFed(File pol, File env, File info) throws MojoExecutionExcept
134134
fb.enableVerboseMode(this.verboseCfgTools);
135135

136136
if (this.configSecretsFile != null) {
137-
if (this.configSecretsPassphrase == null)
138-
throw new MojoExecutionException("Passphrase for secrets file not specified!");
139-
fb.setSecrets(this.configSecretsFile, this.configSecretsPassphrase);
137+
if (this.configSecretsKey == null)
138+
throw new MojoExecutionException("Key file for secrets is not specified!");
139+
fb.setSecrets(this.configSecretsFile, this.configSecretsKey);
140140
}
141141

142142
File fed = new File(getTempDir(), PROJECT_NAME + ".fed");

0 commit comments

Comments
 (0)