Documentation
¶
Overview ¶
Package token issues and verifies opaque, database-backed security tokens.
Only the presented value contains the secret. Applications persist the selector and SHA-256 digest, deliver Presented to the user, and discard it after delivery. Parsing a presented value reproduces only the lookup selector and digest.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidToken is returned for every malformed token. It deliberately // carries no token fragments or parsing details. ErrInvalidToken = errors.New("token: invalid token") )
Functions ¶
func MatchDigest ¶
MatchDigest compares a stored digest with a parsed candidate in constant time. Invalid digest lengths never match, but still execute a full digest comparison.
Types ¶
type Issued ¶
Issued contains the public selector, the digest to persist, and the complete value to deliver. Presented is the only returned value containing the secret.
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
Issuer issues tokens from an explicit entropy source. Use Issue for the production crypto/rand path; an Issuer is primarily useful for deterministic tests or applications with their own cryptographic reader.
type Parsed ¶
type Parsed struct {
Selector string
// contains filtered or unexported fields
}
Parsed contains the public selector and derived digest of a presented token. It never retains or exposes the raw secret.