Get started with Secrets Store
Turn the secrets store on for your realm, store a secret in your own vault, and give a colleague access to it, with every call.
AvailableAPI
In this walkthrough you turn the store on for the realm foobar, then maya keeps the staging database password in
her own vault and gives her colleague ben read access to it for two weeks. At the end, ben reads the password
under his own sign-in, and nothing else in maya’s vault is open to him.
Before you begin
Section titled “Before you begin”- You are a realm administrator of
foobar: a member of a group holdingRealmOwner. The realm has the usersmayaandben, who need no privilege of their own. - Everything is done through the API; there are no screens yet.
- Each step says who makes the call. Each person signs in and keeps their own session in
$CVYUH_SESSION: Call the API shows how. - Every Secrets Store call goes to
https://foobar.cvyuh.com/api/v0/vault/managed/v1.
Store a secret and share it
Section titled “Store a secret and share it”-
Turn the store on. As a realm administrator:
Terminal window curl -X POST https://foobar.cvyuh.com/api/v0/vault/managed/v1/enable \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"The realm writes its Realm settings at their defaults and answers
201(200if the store was already on):{ "data": { "enabled": true } }Until this call, every other call to the store answers
409. Anyone who isn’t a realm administrator is refused (403). -
Ben opens the store once. Signed in as
ben, read the store’s settings:Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/config \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"{"data": { "max_versions": 10, "cas_required": false, "delete_version_after": "0s" }}A user’s own key is made the first time they use the store. A grant is sealed to the grantee’s key, so
benneeds one beforemayacan grant him anything. Skip this, and step 4 answers404. -
Maya stores the password. Signed in as
maya, write it into her own vault (me) under a path she chooses:Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/data/db/staging \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "data": { "user": "app", "password": "<password>" } }'The realm answers
200with version 1’s metadata:{"data": {"created_time": "<RFC 3339 time>","custom_metadata": null,"deletion_time": "","destroyed": false,"version": 1}} -
Maya gives Ben access. A
usegrant lets him read the current value and nothing else;validToends it by itself:Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/grants/db/staging \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "user": "ben", "access": "use", "validTo": "<RFC 3339 time>" }'The realm seals a copy of the secret to
ben’s key and answers201:{"data": {"edgeId": "<grant id>","user": "ben","access": "use","validTo": "<RFC 3339 time>","grantedBy": "maya","live": true}} -
Ben finds it and reads it. Signed in as
ben, list what has been shared with him:Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/shared \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"{ "data": { "keys": [ { "vault": "user/maya", "path": "db/staging", "access": "use" } ] } }Then read the secret in
maya’s vault:Terminal window curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/user/maya/data/db/staging \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"{"data": {"data": { "user": "app", "password": "<password>" },"metadata": { "version": 1, "created_time": "<RFC 3339 time>", "…": "…" }}}
Check it worked
Section titled “Check it worked”- As
ben, read any other path inmaya’s vault: the realm answers404, as if it weren’t there. - As
maya, list the grants on the secret withcurl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/grants/db/staging -H "Cookie: x-cvyuh-token=$CVYUH_SESSION": the grant tobenshows"live": trueuntil itsvalidTo.
If something goes wrong
Section titled “If something goes wrong”| Symptom | Cause | Fix |
|---|---|---|
Any call answers 409 | The store isn’t on | Step 1, as a realm administrator |
Step 1 answers 403 | The caller isn’t a realm administrator | Sign in as a member of a group holding RealmOwner |
Step 4 answers 404 | ben hasn’t used the store yet | Step 2, signed in as ben, then step 4 again |
ben’s read answers 404 | The grant has ended, or the path is wrong | List the grants as maya; check "live" and the path |
Every error is in Secrets Store API.