Skip to content

Commit 3021c30

Browse files
kevin-loehfelmschavis
authored andcommitted
added documentation for mongodb atlas database secrets engine eventua… (#24152)
* added documentation for mongodb atlas database secrets engine eventual consistency
1 parent fe20e9a commit 3021c30

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

changelog/24152.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
website/docs: Add note about eventual consietency with the MongoDB Atlas database secrets engine
3+
```

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

+63-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,69 @@ the proper permissions, it can generate credentials.
7373
lease_duration 1h
7474
lease_renewable true
7575
password FBYwnnh-fwc0quxtKf11
76-
username v-my-role-DKbQEg6uRn
76+
username v-my-password-role-DKbQEg6uRn
77+
```
78+
79+
Each invocation of the command generates a new credential.
80+
81+
MongoDB Atlas database credentials eventually become consistent when the
82+
[MongoDB Atlas Admin API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/)
83+
coordinates with hosted clusters in your Atlas project. You cannot use the
84+
credentials successfully until the consistency process completes.
85+
86+
If you plan to use MongoDB Atlas credentials in a pipeline, you may need to add
87+
a time delay or secondary process to account for the time required to establish consistency.
88+
89+
#### Client certificate credentials
90+
91+
1. Configure a role that maps a name in Vault to a MongoDB Atlas command that executes and
92+
creates the X509 type database user credential:
93+
94+
```shell-session
95+
$ vault write database/roles/my-dynamic-certificate-role \
96+
db_name=my-mongodbatlas-database \
97+
creation_statements='{"database_name": "$external", "x509Type": "CUSTOMER", "roles": [{"databaseName":"<db_name>","roleName":"readWrite"}]}' \
98+
default_ttl="1h" \
99+
max_ttl="24h" \
100+
credential_type="client_certificate" \
101+
credential_config=ca_cert="$(cat path/to/ca_cert.pem)" \
102+
credential_config=ca_private_key="$(cat path/to/private_key.pem)" \
103+
credential_config=key_type="rsa" \
104+
credential_config=key_bits=2048 \
105+
credential_config=signature_bits=256 \
106+
credential_config=common_name_template="{{.DisplayName}}_{{.RoleName}}_{{unix_time}}"
107+
Success! Data written to: database/roles/my-dynamic-certificate-role
108+
```
109+
110+
1. Generate a new credential by reading from the `/creds` endpoint with the name
111+
of the role:
112+
113+
```shell-session
114+
$ vault read database/creds/my-dynamic-certificate-role
115+
Key Value
116+
--- -----
117+
request_id b6556b2d-c379-5a92-465d-6597c506c821
118+
lease_id database/creds/my-dynamic-certificate-role/AZ5tao6NjLJctx7fm1bujKEL
119+
lease_duration 1h
120+
lease_renewable true
121+
client_certificate -----BEGIN CERTIFICATE-----
122+
...
123+
-----END CERTIFICATE-----
124+
private_key -----BEGIN PRIVATE KEY-----
125+
...
126+
-----END PRIVATE KEY-----
127+
private_key_type rsa
128+
username CN=token_my-dynamic-certificate-role_1677262121
129+
```
130+
131+
## Client certificate authentication
132+
133+
MongoDB Atlas supports [X.509 client certificate based authentication](https://www.mongodb.com/docs/manual/tutorial/configure-x509-client-authentication/)
134+
for enhanced authentication security as an alternative to username and password authentication.
135+
The MongoDB Atlas database plugin can be used to manage client certificate credentials for
136+
MongoDB Atlas users by using `client_certificate` [credential_type](/vault/api-docs/secret/databases#credential_type).
137+
138+
See the [usage](/vault/docs/secrets/databases/mongodbatlas#usage) section for examples using dynamic roles.
77139

78140
## API
79141

0 commit comments

Comments
 (0)