Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConfirmation ¶
NewConfirmation creates a new string token that includes a random secret and expires after 5 minutes.
Types ¶
type Confirmation ¶
type Confirmation struct { ID ulid.ULID `msgpack:"id"` Secret string `msgpack:"secret"` ExpiresAt time.Time `msgpack:"expires_at"` }
Confirmation protects access to a resource by encoding an ID with a cryptographically secure secret and an expiration time.
func (*Confirmation) Create ¶
func (t *Confirmation) Create() (_ string, err error)
Create a new base64 encoded string from the token data. Note that callers should use the NewResourceToken method to ensure that all fields are present; this method is primarily exposed for the tests.
func (*Confirmation) Decode ¶
func (t *Confirmation) Decode(token string) (err error)
Decode a base64 encoded string into the struct.
func (*Confirmation) IsExpired ¶
func (t *Confirmation) IsExpired() bool
func (*Confirmation) IsValid ¶ added in v0.7.0
func (t *Confirmation) IsValid(id ulid.ULID) bool
Returns true if the token is valid for the given ID.
Click to show internal directories.
Click to hide internal directories.