Skip to content
Secrets StoreMarkdown

Share secrets with a team

Keep a team's secrets in its group's vault, so access follows the group's membership with nothing to hand over.

API

A team’s credentials belong to the team, not to whoever happened to write them. Kept in the group’s vault, they are sealed under the group’s own key: every member reads and writes them, someone who joins the group reads what the others wrote, and someone who leaves is refused from their next request.

Before you start: a realm administrator, holding RealmOwner or a privilege of your own that allows changing groups, creates the group and manages its members; the members then keep the secrets, with no privilege of their own. Each call is made with the caller’s own session in $CVYUH_SESSION (Call the API shows how).

  1. As a realm administrator, create the engineering group:

    Terminal window
    curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/group?id=engineering" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "displayName": "Engineering" }'

    The realm answers 201 with the group and its revision, rev.

  2. Add maya and ben as members, one call each, with the group’s current rev:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/objects/v1/group/engineering/relationships/member \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -H 'If-Match: "<rev>"' \
    -d '{ "targetId": "maya" }'
  3. As maya, write a team secret:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/group/engineering/data/deploy/key \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "data": { "key": "<deploy key>" } }'

    The first member to open the group’s vault makes the group’s key.

  4. As ben, read it:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/group/engineering/data/deploy/key \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

Someone not in the group who tries the same read is refused (403). Every member can also give grants on the group’s secrets, for someone outside the team who needs one.

To take ben off the team, a realm administrator removes him from the group, with the group’s current rev:

Terminal window
curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/group/engineering/relationships/member/ben \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H 'If-Match: "<rev>"'

He is refused from his next request. What he already read stays with him: write new values for every secret in the group’s vault he used, and change the credential where it is used. If he was the last to write a secret that has grants on it and is later deleted, writing it again also restarts those grants.