tokens

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfirmation

func NewConfirmation(id ulid.ULID) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL