tokens

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenNotFound = errors.New("The passed token has either expired or never existed")
)

Functions

This section is empty.

Types

type Store

type Store interface {
	// Commission creates a single use token that expires after the given timeout.
	Commission(ctx context.Context, t time.Duration, k string, v interface{}) (string, error)
	// Peek gets the data the token references without changing its lifetime.
	Peek(ctx context.Context, token string, v interface{}) error
	// Extend sets the new duration before an existing token times out. Note that it doesn't
	// take into account how long the old token had to expire, as it uses the new duration
	// entirely.
	Extend(ctx context.Context, token string, t time.Duration, v interface{}) error
	// Reset changes the contents of the token without changing it's TTL
	Reset(ctx context.Context, k string, v interface{}) error
	// Decommission loads the value referenced by the token and dispenses of the token,
	// making it unvailable for further use.
	Decommission(ctx context.Context, token string, v interface{}) error
	// Revoke renders the token generated for the given key useless.
	Revoke(ctx context.Context, key string) error
}

func NewStore

func NewStore(r *redis.Client, secret []byte) Store

Jump to

Keyboard shortcuts

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