Skip to content
Secrets StoreMarkdown

Send a secret once

Hand one version of a secret to someone through a link that works once and then expires.

API

ben is starting today and needs his first password, or needs one value tonight. A one-time share sends it once: the first read of the link gets the value, and the link is spent. There is no lasting access to take back, and a link that leaks later gives nothing.

Before you start: you may view the secret: you own it, or hold a view grant on it. The reader has an account in the realm. Each of you is signed in with your own session in $CVYUH_SESSION (Call the API shows how).

  1. As maya, make a share of onboarding/ben that waits an hour, for ben alone:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/me/share/onboarding/ben \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "ttl": 3600, "recipient": "ben" }'

    The realm answers 201 with { "link": "<link>", "expires_at": "<RFC 3339 time>" } under data. Leave out recipient for anyone in the realm who has the link, and add "version": <n> to share an older version.

  2. Send the link to ben, by any channel.

  3. As ben, read it:

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

    The realm answers 200 with the values.

Send the same read again: it answers 404, for ben too. A share no one reads expires on its own. A lifetime longer than the realm allows, a week by default, answers 400.

If ben’s first read answers 404 and the share hadn’t expired, someone else read it: treat the value as exposed, change the secret, and send him a new share.

A share can’t be withdrawn before it is read; it lasts until it is read or expires. If you sent it to the wrong person, change the secret at once, so the share carries a value that no longer works. Keep ttl short.