You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding support for HashiCorp Vault dynamic database credentials (#401)
* Signed-off-by: Ilmar Kerm <[email protected]>
Add support for "database" secret engine, also all other secret engine types by using Logical() backend type.
Since Vault is creating common users in CDB, it needs to have CREATE/ALTER/DROP USER privileges on all containers. Here is a modification of the documented Vault Oracle plugin admin user privileges.
60
+
61
+
```sql
62
+
GRANT CREATE USER to c##vaultadmin WITH ADMIN OPTION container=all;
63
+
GRANT ALTER USER to c##vaultadmin WITH ADMIN OPTION container=all;
64
+
GRANT DROP USER to c##vaultadmin WITH ADMIN OPTION container=all;
65
+
GRANT CREATE SESSION to c##vaultadmin WITH ADMIN OPTION;
66
+
GRANTSELECTon gv_$session to c##vaultadmin;
67
+
GRANTSELECTon v_$sql to c##vaultadmin;
68
+
GRANT ALTER SYSTEM to c##vaultadmin WITH ADMIN OPTION;
69
+
```
70
+
71
+
Create no authentication user in Oracle database, that has actual monitoring privileges.
72
+
73
+
```sql
74
+
CREATEUSERc##exporter NO AUTHENTICATION;
75
+
GRANT create session TO c##exporter;
76
+
GRANT all necessary privileges that Exporter needs TO c##exporter;
77
+
```
78
+
79
+
Create database role in Vault:
80
+
81
+
```sh
82
+
vault write database/roles/mydb_exporter \
83
+
db_name=mydb \
84
+
creation_statements='CREATE USER {{username}} IDENTIFIED BY "{{password}}"; GRANT CREATE SESSION TO {{username}}; ALTER USER c##exporter GRANT CONNECT THROUGH {{username}};' \
85
+
default_ttl="7d" \
86
+
max_ttl="10d"
87
+
```
88
+
89
+
NB! Make sure to restart Exporter before TTL above expires, this will fetch new database credentials. When TTL expires, Vault will drop the dynamically created database users.
90
+
91
+
And create database config in Exporter:
92
+
93
+
```yaml
94
+
databases:
95
+
mydb:
96
+
vault:
97
+
hashicorp:
98
+
proxySocket: /var/run/vault/vault.sock
99
+
mountType: database
100
+
mountName: database
101
+
secretPath: mydb_exporter
102
+
useAsProxyFor: c##exporter
103
+
```
104
+
38
105
### Authentication
39
106
40
107
In this first version it currently only supports queries via HashiCorp Vault Proxy configured to run on the local host and listening on a Unix socket. Currently also required use_auto_auth_token option to be set.
0 commit comments