Skip to content

Commit 08e8776

Browse files
vinay-gopalanfairclothjmschavis
authored
Add documentation for new rootless password rotation workflow for DB Static Roles (#28374)
Co-authored-by: John-Michael Faircloth <[email protected]> Co-authored-by: Sarah Chavis <[email protected]>
1 parent 69411d7 commit 08e8776

File tree

3 files changed

+76
-3
lines changed

3 files changed

+76
-3
lines changed

website/content/api-docs/secret/databases/index.mdx

+5
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ this in order to know the password.
534534
- `username` `(string: <required>)` – Specifies the database username that this
535535
Vault role corresponds to.
536536

537+
- `self_managed_password` `(string)` – <EnterpriseAlert product="vault" inline />
538+
The password corresponding to the username in the database. Required when using
539+
the Rootless Password Rotation workflow for static roles. Only enabled for select
540+
DB engines (Postgres).
541+
537542
- `db_name` `(string: <required>)` - The name of the database connection to use
538543
for this role.
539544

website/content/api-docs/secret/databases/postgresql.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ has a number of parameters to further configure a connection.
5151

5252
- `password` `(string: "")` - The root credential password used in the connection URL.
5353

54+
- `self_managed` `(boolean: "false")` - <EnterpriseAlert product="vault" inline /> If
55+
set, allows onboarding static roles with a rootless connection configuration. Mutually
56+
exclusive with `username` and `password`. If set, will force `verify_connection` to be false.
57+
5458
- `tls_ca` `(string: "")` - The x509 CA file for validating the certificate
5559
presented by the PostgreSQL server. Must be PEM encoded.
5660

website/content/docs/secrets/databases/postgresql.mdx

+67-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ options, including SSL options, can be found in the [pgx][pgxlib] and
2424

2525
## Capabilities
2626

27-
| Plugin Name | Root Credential Rotation | Dynamic Roles | Static Roles | Username Customization |
28-
| ---------------------------- | ------------------------ | ------------- | ------------ | ---------------------- |
29-
| `postgresql-database-plugin` | Yes | Yes | Yes | Yes (1.7+) |
27+
| Plugin Name | Root Credential Rotation | Dynamic Roles | Static Roles | Username Customization | Credential Types |
28+
| ---------------------------- | ------------------------ | ------------- | ------------ | ---------------------- | ---------------------------- |
29+
| `postgresql-database-plugin` | Yes | Yes | Yes | Yes (1.7+) | password, gcp_iam |
3030

3131
## Setup
3232

@@ -84,6 +84,70 @@ the proper permission, it can generate credentials.
8484
username v-vaultuse-my-role-x
8585
```
8686

87+
## Rootless Configuration and Password Rotation for Static Roles
88+
89+
<EnterpriseAlert product="vault" />
90+
91+
The PostgreSQL secrets engine supports using Static Roles and its password rotation mechanisms with a Rootless
92+
DB connection configuration. In this workflow, a static DB user can be onboarded onto Vault's static role rotation
93+
mechanism without the need of privileged root accounts to configure the connection. Instead of using a single root
94+
connection, multiple dedicated connections to the DB are made for each static role. This workflow does not support
95+
dynamic roles/credentials.
96+
97+
~> Note: It is **highly recommended** that the DB users being onboarded as static roles
98+
have the minimum set of privileges. Each static role will open a new connection into the DB.
99+
Granting minimum privileges to the DB users being onboarded ensures that multiple
100+
highly-privileged connections to an external system are not being made.
101+
102+
~> Note: Out-of-band password rotations will cause Vault to be out of sync with the state of
103+
the DB user, and will require manually updating the user's password in the external PostgreSQL
104+
DB in order to resolve any errors encountered during rotation.
105+
106+
1. Enable the database secrets engine if it is not already enabled:
107+
108+
```shell-session
109+
$ vault secrets enable database
110+
Success! Enabled the database secrets engine at: database/
111+
```
112+
113+
By default, the secrets engine will enable at the name of the engine. To
114+
enable the secrets engine at a different path, use the `-path` argument.
115+
116+
1. Configure connection to DB without root credentials and enable the rootless
117+
workflow by setting the `self_managed` parameter:
118+
119+
```shell-session
120+
$ vault write database/config/my-postgresql-database \
121+
plugin_name="postgresql-database-plugin" \
122+
allowed_roles="my-role" \
123+
connection_url="postgresql://{{username}}:{{password}}@localhost:5432/database-name" \
124+
self_managed=true
125+
```
126+
127+
1. Configure a static role that creates a dedicated connection to a user in the DB with
128+
the `self_managed_password` parameter:
129+
130+
```shell-session
131+
$ vault write database/static-roles/my-static-role \
132+
db_name="my-postgresql-database" \
133+
username="staticuser" \
134+
self_managed_password="password" \
135+
rotation_period="1h"
136+
```
137+
138+
1. Read static credentials:
139+
140+
```shell-session
141+
$ vault read database/static-creds/static-test
142+
Key Value
143+
--- -----
144+
last_vault_rotation 2024-09-11T14:15:13.764783-07:00
145+
password XZY42BVc-UO5bMsbgxrW
146+
rotation_period 1h
147+
ttl 59m55s
148+
username staticuser
149+
```
150+
87151
## Client x509 certificate authentication
88152

89153
This plugin supports using PostgreSQl's [x509 Client-side Certificate Authentication](https://www.postgresql.org/docs/16/libpq-ssl.html#LIBPQ-SSL-CLIENTCERT).

0 commit comments

Comments
 (0)