tokens

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 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 struct {
	// contains filtered or unexported fields
}

func NewStore

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

func (*Store) Commission

func (ts *Store) Commission(ctx context.Context, t time.Duration, key string, data interface{}) (string, error)

Commission creates a single use token that expires after the given timeout.

func (*Store) Decommission

func (ts *Store) Decommission(ctx context.Context, token string, data interface{}) error

Decommission loads the value referenced by the token and dispenses of the token, making it unvailable for further use.

func (*Store) Extend

func (ts *Store) Extend(ctx context.Context, token string, timeout time.Duration, data 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.

func (*Store) Peek

func (ts *Store) Peek(ctx context.Context, token string, data interface{}) error

Peek gets the data the token references without changing its lifetime.

func (*Store) Reset

func (ts *Store) Reset(ctx context.Context, key string, data interface{}) error

Reset changes the contents of the token without changing it's TTL

func (*Store) Revoke

func (ts *Store) Revoke(ctx context.Context, key string) error

Revoke renders the token generated for the given key useless.

Jump to

Keyboard shortcuts

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