Skip to content

Commit f3483ab

Browse files
committed
Add TLS and mTLS support
1 parent cd01494 commit f3483ab

18 files changed

Lines changed: 6558 additions & 4161 deletions

File tree

.github/workflows/build.yml

Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
branches:
44
- master
55
pull_request:
6+
branches:
7+
- master
68

79
jobs:
810
build:
@@ -26,68 +28,15 @@ jobs:
2628
- name: npm run test
2729
run: npm run test
2830

29-
integration:
31+
e2e-tls:
3032
runs-on: ubuntu-latest
3133

32-
services:
33-
vaultBasic:
34-
image: vault:1.2.3
35-
ports:
36-
- 8200/tcp
37-
env:
38-
VAULT_DEV_ROOT_TOKEN_ID: testtoken
39-
options: --cap-add=IPC_LOCK
40-
vaultEnterprise:
41-
image: hashicorp/vault-enterprise:1.3.0_ent
42-
ports:
43-
- 8200/tcp
44-
env:
45-
VAULT_DEV_ROOT_TOKEN_ID: testtoken
46-
options: --cap-add=IPC_LOCK
47-
4834
steps:
49-
- uses: actions/checkout@v1
50-
- uses: actions/setup-node@v1
51-
with:
52-
node-version: ''
53-
- name: setup npm cache
54-
uses: actions/cache@v1
55-
with:
56-
path: ~/.npm
57-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
58-
restore-keys: |
59-
${{ runner.os }}-node-
60-
- name: npm install
61-
run: npm ci
62-
- name: npm build
63-
run: npm run build
64-
- name: npm run test:integration:basic
65-
run: npm run test:integration:basic
66-
env:
67-
VAULT_HOST: localhost
68-
VAULT_PORT: ${{ job.services.vaultBasic.ports[8200] }}
69-
CI: true
70-
- name: npm run test:integration:enterprise
71-
run: npm run test:integration:enterprise
72-
env:
73-
VAULT_HOST: localhost
74-
VAULT_PORT: ${{ job.services.vaultEnterprise.ports[8200] }}
75-
CI: true
76-
77-
e2e:
78-
runs-on: ubuntu-latest
35+
- uses: actions/checkout@v1
7936

80-
services:
81-
vault:
82-
image: vault:1.3.0
83-
ports:
84-
- 8200/tcp
85-
env:
86-
VAULT_DEV_ROOT_TOKEN_ID: testtoken
87-
options: --cap-add=IPC_LOCK
37+
- name: Run docker-compose
38+
run: docker-compose up -d vault-tls
8839

89-
steps:
90-
- uses: actions/checkout@v1
9140
- uses: actions/setup-node@v1
9241
with:
9342
node-version: ''
@@ -103,41 +52,54 @@ jobs:
10352
- name: npm build
10453
run: npm run build
10554
- name: setup vault
106-
run: node ./integrationTests/e2e/setup.js
55+
run: node ./integrationTests/e2e-tls/setup.js
10756
env:
10857
VAULT_HOST: localhost
109-
VAULT_PORT: ${{ job.services.vault.ports[8200] }}
58+
VAULT_PORT: 8200
59+
VAULTCA: ${{ secrets.VAULTCA }}
60+
VAULT_CLIENT_CERT: ${{ secrets.VAULT_CLIENT_CERT }}
61+
VAULT_CLIENT_KEY: ${{ secrets.VAULT_CLIENT_KEY }}
11062
- name: use vault action (default K/V version 2)
11163
uses: ./
11264
id: kv-secrets
11365
with:
114-
url: http://localhost:${{ job.services.vault.ports[8200] }}
115-
token: testtoken
66+
url: https://localhost:8200
67+
token: ${{ env.VAULT_TOKEN }}
68+
caCertificate: ${{ secrets.VAULTCA }}
69+
clientCertificate: ${{ secrets.VAULT_CLIENT_CERT }}
70+
clientKey: ${{ secrets.VAULT_CLIENT_KEY }}
11671
secrets: |
11772
test secret ;
11873
test secret | NAMED_SECRET ;
11974
nested/test otherSecret ;
75+
12076
- name: use vault action (custom K/V version 1)
12177
uses: ./
12278
with:
123-
url: http://localhost:${{ job.services.vault.ports[8200] }}
124-
token: testtoken
79+
url: https://localhost:8200
80+
token: ${{ env.VAULT_TOKEN }}
12581
path: my-secret
12682
kv-version: 1
83+
caCertificate: ${{ secrets.VAULTCA }}
84+
clientCertificate: ${{ secrets.VAULT_CLIENT_CERT }}
85+
clientKey: ${{ secrets.VAULT_CLIENT_KEY }}
12786
secrets: |
12887
test altSecret ;
12988
test altSecret | NAMED_ALTSECRET ;
13089
nested/test otherAltSecret ;
13190
- name: use vault action (using cubbyhole engine)
13291
uses: ./
13392
with:
134-
url: http://localhost:${{ job.services.vault.ports[8200] }}
135-
token: testtoken
93+
url: https://localhost:8200
94+
token: ${{ env.VAULT_TOKEN }}
13695
secrets: |
13796
/cubbyhole/test foo ;
13897
/cubbyhole/test zip | NAMED_CUBBYSECRET ;
98+
caCertificate: ${{ secrets.VAULTCA }}
99+
clientCertificate: ${{ secrets.VAULT_CLIENT_CERT }}
100+
clientKey: ${{ secrets.VAULT_CLIENT_KEY }}
139101
- name: verify
140-
run: npm run test:e2e
102+
run: npm run test:e2e-tls
141103
env:
142104
OTHER_SECRET_OUTPUT: ${{ steps.kv-secrets.outputs.otherSecret }}
143105

action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ inputs:
4343
description: 'Whether or not export secrets as environment variables.'
4444
default: 'true'
4545
required: false
46+
caCertificate:
47+
description: 'Base64 encoded CA certificate to verify the Vault server certificate.'
48+
required: false
49+
clientCertificate:
50+
description: 'Base64 encoded client certificate for mTLS communication with the Vault server.'
51+
required: false
52+
clientKey:
53+
description: 'Base64 encoded client key for mTLS communication with the Vault server.'
54+
required: false
55+
tlsSkipVerify:
56+
description: 'When set to true, disables verification of the Vault server certificate. Setting this to true in production is not recommended.'
57+
required: false
58+
default: "false"
4659
runs:
4760
using: 'node12'
4861
main: 'dist/index.js'

0 commit comments

Comments
 (0)