Skip to content

Commit 108554c

Browse files
committed
improved ad secret management documentation
Signed-off-by: Rod Anami <[email protected]>
1 parent acc5cac commit 108554c

File tree

4 files changed

+103
-85
lines changed

4 files changed

+103
-85
lines changed

container/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ services:
1818
- IPC_LOCK
1919
entrypoint: vault server -config=/vault/config/vault.hcl
2020
extra_hosts:
21-
- "ldap.chatopsknight.com:10.88.0.10"
21+
- "ldap.chatopsknight.com:10.88.0.11"
2222

docs/AD-Functions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Hashi Vault JS
22

3+
## Important Notice
4+
5+
The Active Directory (AD) secrets engine has been deprecated as of the Vault v1.13 release. HashiCorp will continue to support the AD secrets engine in maintenance mode for six major Vault releases, meaning up to v1.19.
6+
37
## AD Functions List
48

59
* Vault document [reference](https://www.vaultproject.io/api-docs/secret/ad)

docs/Test-environment.md

Lines changed: 89 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
export PATH=$PATH:/path/to/vault
1616
```
1717

18-
* Modify Docker compose configuration on this file: `docker-compose.yaml`
18+
### Modify Docker compose configuration on this file: `docker-compose.yaml`
1919

2020
```yaml
2121
version: '3'
@@ -37,7 +37,7 @@ services:
3737
entrypoint: vault server -config=/vault/config/vault.hcl
3838
```
3939
40-
* Create a Vault server configuration file named: `vault.hcl`
40+
### Create a Vault server configuration file named: `vault.hcl`
4141

4242
```hcl
4343
storage "file" {
@@ -56,7 +56,7 @@ default_lease_ttl = "12h"
5656
api_addr = "http://127.0.0.1:8200"
5757
```
5858

59-
* Create volumes and copy any certificate/key that you have
59+
### Create volumes and copy any certificate/key that you have
6060

6161
```shell
6262
# Create volumes on your local filesystem, for cloud environments you'll need a private volume
@@ -246,86 +246,98 @@ api_addr = "http://127.0.0.1:8200"
246246
EOF
247247
```
248248

249-
* Create an AppRole with role_id and secret_id
249+
## Create an AppRole with role_id and secret_id
250250

251-
```shell
252-
# Policy indicates the permissions and scopes an AppRole will have
253-
vault policy write my-policy my-policy-permissions.hcl
251+
```shell
252+
# Policy indicates the permissions and scopes an AppRole will have
253+
vault policy write my-policy my-policy-permissions.hcl
254254
255-
# Create an AppRole, usually one per application
256-
vault write auth/approle/role/my-role secret_id_ttl="720h" token_ttl="12h"\
257-
token_max_tll="12h" policies="my-policy"
255+
# Create an AppRole, usually one per application
256+
vault write auth/approle/role/my-role secret_id_ttl="720h" token_ttl="12h"\
257+
token_max_tll="12h" policies="my-policy"
258258
259-
# Get the AppRole role-id
260-
vault read auth/approle/role/my-role/role-id
259+
# Get the AppRole role-id
260+
vault read auth/approle/role/my-role/role-id
261261
262-
# Get the initial secret-id tied to the role-id
263-
vault write -f auth/approle/role/my-role/secret-id
262+
# Get the initial secret-id tied to the role-id
263+
vault write -f auth/approle/role/my-role/secret-id
264264
```
265265

266-
* Enable kubernetes auth method and create a role
266+
## Enable kubernetes auth method and create a role
267267

268-
```shell
269-
# Enable kubernetes auth method and mount it on default auth/kubernetes
270-
vault auth enable kubernetes
271-
272-
# Get you K8s cluster info
273-
kubectl cluster-info
274-
275-
# Configure a service account for the vault
276-
kubectl apply -f ./tests/k8s-service-account.yaml
277-
278-
# Find out the vault-auth service account token
279-
kubectl get secret <secret_name> -o jsonpath={.data.token} | base64 -d
280-
281-
# Configure Vault K8s auth method
282-
vault write auth/kubernetes/config \
283-
token_reviewer_jwt="<your reviewer service account JWT>" \
284-
kubernetes_host=https://192.168.99.119:8443 \
285-
286-
287-
# Create a named role
288-
vault write auth/kubernetes/role/my-role \
289-
bound_service_account_names=vault-auth \
290-
bound_service_account_namespaces=default \
291-
policies=default \
292-
ttl=1h
293-
294-
# Test a login using K8s auth method
295-
vault write auth/kubernetes/login \
296-
role=my-role \
297-
jwt="<your reviewer service account JWT>"
298-
```
268+
```shell
269+
# Enable kubernetes auth method and mount it on default auth/kubernetes
270+
vault auth enable kubernetes
299271
300-
* Enable TLS cert auth method and create a cert
272+
# Get you K8s cluster info
273+
kubectl cluster-info
301274
302-
```shell
303-
# Enable TLS Certificate auth method
304-
vault auth enable cert
305-
306-
# Create a PKI role to issue certificates
307-
vault write pki_int/roles/vault-cert \
308-
allow_any_name=true \
309-
max_ttl=720h \
310-
generate_lease=true
311-
312-
# Create a policy for the certificates issued
313-
vault policy write cert-policy ./policies/cert-policy.hcl
314-
315-
# Issue a certificate based on the create role
316-
vault write -format=json pki_int/issue/vault-cert \
317-
common_name=vault-cert | tee \
318-
>(jq -r .data.certificate > vault-cert-certificate.pem) \
319-
>(jq -r .data.issuing_ca > vault-cert-issuing-ca.pem) \
320-
>(jq -r .data.private_key > vault-cert-private-key.pem)
321-
322-
# Create a cert for authentication
323-
vault write auth/cert/certs/vault-cert \
324-
display_name=vault-cert \
325-
policies=cert \
326-
327-
328-
# Test cert login
329-
vault login -method=cert -client-cert=vault-cert-certificate.pem \
330-
-client-key=vault-cert-private-key.pem
331-
```
275+
# Configure a service account for the vault
276+
kubectl apply -f ./tests/k8s-service-account.yaml
277+
278+
# Find out the vault-auth service account token
279+
kubectl get secret <secret_name> -o jsonpath={.data.token} | base64 -d
280+
281+
# Configure Vault K8s auth method
282+
vault write auth/kubernetes/config \
283+
token_reviewer_jwt="<your reviewer service account JWT>" \
284+
kubernetes_host=https://192.168.99.119:8443 \
285+
286+
287+
# Create a named role
288+
vault write auth/kubernetes/role/my-role \
289+
bound_service_account_names=vault-auth \
290+
bound_service_account_namespaces=default \
291+
policies=default \
292+
ttl=1h
293+
294+
# Test a login using K8s auth method
295+
vault write auth/kubernetes/login \
296+
role=my-role \
297+
jwt="<your reviewer service account JWT>"
298+
```
299+
300+
## Enable TLS cert auth method and create a cert
301+
302+
```shell
303+
# Enable TLS Certificate auth method
304+
vault auth enable cert
305+
306+
# Create a PKI role to issue certificates
307+
vault write pki_int/roles/vault-cert \
308+
allow_any_name=true \
309+
max_ttl=720h \
310+
generate_lease=true
311+
312+
# Create a policy for the certificates issued
313+
vault policy write cert-policy ./policies/cert-policy.hcl
314+
315+
# Issue a certificate based on the create role
316+
vault write -format=json pki_int/issue/vault-cert \
317+
common_name=vault-cert | tee \
318+
>(jq -r .data.certificate > vault-cert-certificate.pem) \
319+
>(jq -r .data.issuing_ca > vault-cert-issuing-ca.pem) \
320+
>(jq -r .data.private_key > vault-cert-private-key.pem)
321+
322+
# Create a cert for authentication
323+
vault write auth/cert/certs/vault-cert \
324+
display_name=vault-cert \
325+
policies=cert \
326+
327+
328+
# Test cert login
329+
vault login -method=cert -client-cert=vault-cert-certificate.pem \
330+
-client-key=vault-cert-private-key.pem
331+
```
332+
333+
## Enable AD secret engine and configure it
334+
335+
```shell
336+
vault write ad/config \
337+
binddn="cn=admin,dc=chatopsknight,dc=com" \
338+
bindpass=$LDAP_ADMIN_PASSWORD \
339+
url=ldaps://ldap.chatopsknight.com \
340+
userdn="dc=chatopsknight,dc=com" \
341+
342+
insecure_tls=false
343+
```

tests/AD-smoke-test.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const vault = new Vault( {
1616
cacert: CACert,
1717
baseUrl: VaultUrl,
1818
rootPath: 'ad',
19-
timeout: 3000,
19+
timeout: 5000,
2020
proxy: false
2121
});
2222

@@ -38,14 +38,14 @@ const SetName = "sre-team";
3838

3939
const LibraryPayload1 = {
4040
name: SetName,
41-
service_account_names: ['mathias.thulmann@chatopsknight.com'],
41+
service_account_names: ['john.kane@chatopsknight.com'],
4242
ttl: '1h',
4343
max_ttl: '2h',
4444
disable_check_in_enforcement: false
4545
};
4646
const LibraryPayload2 = {
4747
name: SetName,
48-
service_account_names: ['mathias.thulmann@chatopsknight.com', '[email protected]'],
48+
service_account_names: ['john.kane@chatopsknight.com', '[email protected]'],
4949
ttl: '6h',
5050
max_ttl: '12h',
5151
disable_check_in_enforcement: false
@@ -58,7 +58,7 @@ const CredCheckOut = {
5858

5959
const CredCheckIn1 = {
6060
name: SetName,
61-
service_account_names: ['mathias.thulmann@chatopsknight.com']
61+
service_account_names: ['john.kane@chatopsknight.com']
6262
}
6363

6464
const CredCheckIn2 = {
@@ -106,10 +106,12 @@ vault.createADLibrary(RootToken, LibraryPayload1).then(function(data){
106106
console.error('2> updateADLibrary error:\n',updateError.response.data);
107107
});
108108
}).catch(function(createError){
109-
console.error('3> createADLibrary error:\n',createError);
110-
console.error('3> createADLibrary error:\n',createError.response.data);
109+
console.error('1> createADLibrary error:\n',createError);
110+
console.error('1> createADLibrary error:\n',createError.response.data);
111111
});
112112

113113
// Forcing the credential checkin manually
114114
// vault write ad/library/sre-team/check-in [email protected]
115-
// vault write ad/library/sre-team/check-in [email protected]
115+
// vault write ad/library/sre-team/check-in [email protected]
116+
// Cleaning up the AD library
117+
// vault lease revoke -prefix -force ad/library/sre-team/check-out/

0 commit comments

Comments
 (0)