Skip to content
Secrets StoreMarkdown

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.

  • You are a realm administrator of foobar: a member of a group holding RealmOwner. The realm has the users maya and ben, 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.
  1. 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 (200 if 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).

  2. 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 ben needs one before maya can grant him anything. Skip this, and step 4 answers 404.

  3. 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 200 with version 1’s metadata:

    {
    "data": {
    "created_time": "<RFC 3339 time>",
    "custom_metadata": null,
    "deletion_time": "",
    "destroyed": false,
    "version": 1
    }
    }
  4. Maya gives Ben access. A use grant lets him read the current value and nothing else; validTo ends 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 answers 201:

    {
    "data": {
    "edgeId": "<grant id>",
    "user": "ben",
    "access": "use",
    "validTo": "<RFC 3339 time>",
    "grantedBy": "maya",
    "live": true
    }
    }
  5. 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>", "…": "…" }
    }
    }
  • As ben, read any other path in maya’s vault: the realm answers 404, as if it weren’t there.
  • As maya, list the grants on the secret with curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/grants/db/staging -H "Cookie: x-cvyuh-token=$CVYUH_SESSION": the grant to ben shows "live": true until its validTo.
SymptomCauseFix
Any call answers 409The store isn’t onStep 1, as a realm administrator
Step 1 answers 403The caller isn’t a realm administratorSign in as a member of a group holding RealmOwner
Step 4 answers 404ben hasn’t used the store yetStep 2, signed in as ben, then step 4 again
ben’s read answers 404The grant has ended, or the path is wrongList the grants as maya; check "live" and the path

Every error is in Secrets Store API.