Documentation
¶
Overview ¶
Package token signs and verifies media access tokens, shared by the host signer and the media gateway so the format cannot drift:
{kid}.{exp}.base64url(HMAC-SHA256(secret, "{scope}|{exp}"))
An item token's scope is an item's, "{ns}/{kind}/{id}" or a version's "{ns}/{kind}/{id}/{version}": every file in the item's private/ or none. A private-file token covers one immutable key, never its siblings. A download token covers one key in download/, which neither private token opens. Tokens are bearer tokens, revoked only by expiry.
Index ¶
Constants ¶
const CookieName = "mt"
CookieName carries an item token in cookie delivery mode.
const DefaultWindow = 4 * time.Hour
DefaultWindow aligns expiries so tokens and URLs repeat within a window.
Variables ¶
Functions ¶
func DownloadScope ¶
DownloadScope is the scope of a download token for key: the key itself, which no item scope equals.
func Expiry ¶
Expiry rounds now+ttl up to a window. Token timestamps store whole Unix seconds, so fractional-second windows round up to whole seconds.
func ItemScope ¶ added in v0.62.0
ItemScope covers every private file of one item: "{ns}/{kind}/{id}", or "{ns}/{kind}/{id}/{version}" for a version's.
func PrivateFileScope ¶ added in v0.114.0
PrivateFileScope covers one private object key, including tenant, app, kind, item and version. Its domain separator keeps it distinct from download and whole-item scopes.
Types ¶
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring signs with the current key and verifies with the current or previous one.
func (Ring) VerifyDownload ¶ added in v0.87.0
VerifyDownload checks tok for the download key "{ns}/{kind}/{id}[/{version}]/download/{name}" at now: that one key's download token.
func (Ring) VerifyPrivate ¶ added in v0.62.0
VerifyPrivate checks an exact-file or whole-item token for a private key.