Skip to content

Commit b7b1097

Browse files
committed
examples: export secrets as files
1 parent 7eaee9e commit b7b1097

File tree

7 files changed

+72
-3
lines changed

7 files changed

+72
-3
lines changed

examples/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
* [forms_wizard](forms_wizard) - multi-step forms;
5353
* [inventory](inventory) - using Concord Inventory to retrieve Ansible's inventory data;
5454
* [inventory_lookup](inventory_lookup) - using the inventory lookup plugin for Ansible;
55+
* [secret_files](secret_files) - how to store and export secrets as files;
5556
* [secrets_lookup](secret_lookup) - using the secret lookup plugin for Ansible;
5657
* [secrets](secrets) - working with Concord's Secrets storage;
5758

examples/secret_files/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Secrets
2+
3+
Example of exporting "secrets" as files.
4+
5+
## Running
6+
7+
1. upload a couple of files as secrets:
8+
```
9+
$ curl -u AD_USERNAME -F name=myFileA -F type=DATA -F storePassword=12345678 -F [email protected] 'http://localhost:8001/api/v1/org/Default/secret'
10+
$ curl -u AD_USERNAME -F name=myFileB -F type=DATA -F storePassword=12345678 -F [email protected] 'http://localhost:8001/api/v1/org/Default/secret'
11+
12+
{
13+
"id" : "8febf8ae-0511-11e8-8c13-fa163ec7b48b",
14+
"result" : "CREATED",
15+
"password" : "12345678",
16+
"ok" : true
17+
}
18+
```
19+
20+
The `storePassword` value is the password you must use to decrypt/export the secret later.
21+
22+
2. start the process:
23+
```
24+
$ ./run.sh localhost:8001
25+
{
26+
"instanceId" : "8ea63d60-10f5-43dd-ba8b-87150fb20182",
27+
"ok" : true
28+
}
29+
```
30+
31+
5. open [the UI](http://localhost:8080), find the process entry and
32+
open its log. You should see messages like these:
33+
```
34+
12:00:55.817 [INFO ] c.w.c.runner.engine.LoggingTask - Public key file: .tmp/public1856673009465277934.key
35+
12:00:55.821 [INFO ] c.w.c.runner.engine.LoggingTask - Private key file: .tmp/private5358774395817724546.key
36+
12:00:55.832 [INFO ] c.w.c.runner.engine.LoggingTask - Credentials: {password=myPassword, username=myUser}
37+
12:00:55.846 [INFO ] c.w.c.runner.engine.LoggingTask - Plain secret: my horrible secret
38+
```

examples/secret_files/concord.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
configuration:
2+
arguments:
3+
# alternatively, a form, an encrypted value or an external
4+
# service can be used to retrieve the password
5+
pwd: "12345678"
6+
7+
flows:
8+
default:
9+
10+
# exporting secrets as files
11+
- set:
12+
myFileA: ${crypto.exportAsFile('myFileA', pwd)}
13+
myFileB: ${crypto.exportAsFile('myFileB', pwd)}
14+
15+
# the resulting variables will contain the path of the exported files
16+
- log: "My file A: ${myFileA}"
17+
- log: "My file B: ${myFileB}"

examples/secret_files/myFileA.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FILE A

examples/secret_files/myFileB.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FILE B

examples/secret_files/run.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
SERVER_ADDR="$1"
4+
5+
rm -rf target && mkdir target
6+
cp -R concord.yml target/
7+
8+
cd target && zip -r payload.zip ./* > /dev/null && cd ..
9+
10+
read -p "Username: " CURL_USER
11+
curl -u ${CURL_USER} -F archive=@target/payload.zip http://${SERVER_ADDR}/api/v1/process

examples/secrets/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Example of using "secrets" in processes.
66

77
1. create a new SSH key pair:
88
```
9-
$ curl -H "Authorization: auBy4eDWrKWsyhiDp3AQiw" -F storePassword=12345678 'http://localhost:8001/api/v1/org/Default/secret/keypair?name=myKey'
9+
$ curl -H "Authorization: auBy4eDWrKWsyhiDp3AQiw" -F storePassword=12345678 -F name=myKey -F type=KEY_PAIR 'http://localhost:8001/api/v1/org/Default/secret'
1010
{
1111
"name" : "myKey",
1212
"publicKey" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCmV6+q6Uh8j8GYl0nzcwTGpjBwY1Dvv3QIAfmdwC8N6HredMl5hV3RCtpplYR7aItTorWVUYF1MMmXYKr6tjgU9hha2N2NogRjgPWzSVuR8GVa7CF155NB4nlUxt5cGidLj5Uwmy/uQm4Mni5pg/kZMGyIf+gMmcuQXDG3TOHwmJ48HOrpqxkUKaft3SYYOy7F8TjWFnmyXNlMCskSEJd5XdLDhyuDhDEXGpDSsT1brsq0WRXtFyBDjjNeYfI4J9jyOCpAXzbDCt7eYoYK+kod/b6RV8nbaxWALx2fwJS0bDhV3a9chwEyat24Ml66Z5LfCabCE7SGpFhTas56xYkH concord-server",
@@ -19,7 +19,7 @@ The `storePassword` value is the password you must use to decrypt/export the sec
1919

2020
2. create a new username/password pair:
2121
```
22-
$ curl -H "Authorization: auBy4eDWrKWsyhiDp3AQiw" -F username=myUser -F password=myPassword -F storePassword=12345678 'http://localhost:8001/api/v1/org/Default/secret/password?name=myCreds'
22+
$ curl -H "Authorization: auBy4eDWrKWsyhiDp3AQiw" -F username=myUser -F password=myPassword -F storePassword=12345678 -F name=myCreds -F type=USERNAME_PASSWORD 'http://localhost:8001/api/v1/org/Default/secret'
2323
{
2424
"exportPassword" : "12345678",
2525
"ok" : true
@@ -30,7 +30,7 @@ For the sake of the example, the same `storePassword` value is used.
3030

3131
3. create a plain value secret:
3232
```
33-
$ curl -H "Authorization: auBy4eDWrKWsyhiDp3AQiw" -F secret='my horrible secret' -F storePassword=12345678 'http://localhost:8001/api/v1/org/Default/secret/plain?name=myValue'
33+
$ curl -H "Authorization: auBy4eDWrKWsyhiDp3AQiw" -F secret='my horrible secret' -F storePassword=12345678 -F name=myValue -F type=DATA 'http://localhost:8001/api/v1/org/Default/secret'
3434
{
3535
"exportPassword" : "12345678",
3636
"ok" : true

0 commit comments

Comments
 (0)