Store a secret
Keep a password or an API key in your own vault, read it back, and read any earlier version of it.
API
You have a password you’d rather not keep in a text file. Stored in your own vault, it is sealed under your own key, so no one else acting as themselves can read it, a realm administrator included, and every change you make is kept as a version you can go back to. Known limitations lists the exceptions, such as someone who can sign in as you.
Before you start: a realm administrator has turned the store on, and you are signed in to the realm with your
session in $CVYUH_SESSION (Call the API shows how).
Store it and read it back
Section titled “Store it and read it back”-
Write the secret under a path you choose, such as
web/github:Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "data": { "user": "maya", "password": "<password>" } }'The realm answers
200with the new version’s metadata. This is version 1. A409means the store isn’t on yet; ask a realm administrator to turn it on. -
Read it back:
Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"The answer carries the values under
data.dataand the version’s metadata underdata.metadata. -
Change one value. A
PATCHmerges what you send into the latest version, as a new version:Terminal window curl -X PATCH https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "data": { "password": "<new password>" } }'A value sent as
nullis removed.
Check it worked
Section titled “Check it worked”Read the first version again:
curl "https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github?version=1" \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"It still holds the original password: a path keeps its last 10 versions unless you or the realm set another limit.
Undo it
Section titled “Undo it”Delete the latest version with a DELETE on https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/web/github, or
the whole secret with a DELETE on …/me/metadata/web/github. See Take back a change.
Related
Section titled “Related”- Versions: how each write becomes a version.
- Vaults: your vault, a group’s and the realm’s.
- Change a secret safely: when someone else writes it too.