-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvaultlab9c-database secrets engine
66 lines (45 loc) · 1.37 KB
/
vaultlab9c-database secrets engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
cd /home/vault/transit-app-example/backend
python3 app.py &
#secrets list
vault secrets list
#db enable
#enable mysql database plugin
vault write database/config/mysql \
plugin_name=mysql-database-plugin \
connection_url="{{username}}:{{password}}@tcp(localhost:3306)/" \
allowed_roles="recordsApp" \
username="hashicorp" \
password="Password123"
#test
vault read database/config/mysql
#test db creds
mysql -u hashicorp -pPassword123
#exit
\q
#rotate
vault write -force database/rotate-root/mysql
#create role
vault write database/roles/recordsApp \
db_name=mysql \
creation_statements="CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}';GRANT ALL ON my_app.* TO '{{name}}'@'%';" \
default_ttl="1h" \
max_ttl="24h"
#create for new app creds
vault read database/creds/recordsApp
#use creds
mysql -u v-token-recordsApp-9aclA2GhXes9l -p
show databases;
#renew revoke creds
vault read database/creds/recordsApp
#lease extension
vault write sys/leases/renew lease_id=database/creds/recordsApp/rh5ToMkbl0H1fVaznEivSlqy increment=3600
#lease lookup
vault write sys/leases/lookup lease_id=database/creds/recordsApp/rh5ToMkbl0H1fVaznEivSlqy
#revoke
vault write sys/leases/revoke lease_id=database/creds/recordsApp/rh5ToMkbl0H1fVaznEivSlqy
#challenge 6
#define the python app
ps -ef | grep app.py
kill -9 <PID>
cd /home/vault/transit-app-example/backend
python3 app.py &