Limit a secret's history
Choose how many versions a secret keeps, let old versions lapse after a time, and label a secret with your own notes.
API
Old credentials kept around are a risk. You can cap how many versions a secret keeps, have each version read as deleted a set time after it was written, and label the secret so others know what it is for.
Before you start: you can write the secret: here, db/prod/root in your own vault. You are signed in with your
session in $CVYUH_SESSION (Call the API shows how).
Set the limits
Section titled “Set the limits”-
Keep only two versions:
Terminal window curl -X PATCH https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/metadata/db/prod/root \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "max_versions": 2 }'From the next write, versions past the limit are dropped for good.
-
Let each version lapse thirty days after it is written:
Terminal window curl -X PATCH https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/metadata/db/prod/root \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "delete_version_after": "720h" }'This applies to versions written from now on. A lapsed version reads as deleted, and can be undeleted until it is destroyed or dropped.
-
Add labels, as text:
Terminal window curl -X PATCH https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/metadata/db/prod/root \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "custom_metadata": { "team": "engineering", "rotates": "monthly" } }'A label sent as
nullis removed.POSTin place ofPATCHreplaces every label.
Each call answers 204.
Check it worked
Section titled “Check it worked”A GET on https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/metadata/db/prod/root shows max_versions,
delete_version_after and custom_metadata. After the third write, oldest_version moves up.
Undo it
Section titled “Undo it”Set max_versions to 0 and delete_version_after to 0s to take the realm’s defaults again. See
Set the realm’s defaults.
Related
Section titled “Related”- Metadata: every field, and its limits.
- Realm settings: the defaults a path takes.