bolt

package module
v0.0.0-...-705d8e6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAccess

func WithAccess(duration time.Duration) Option

WithAccess set the valid time of access token, at least one second.

func WithBucket

func WithBucket(bucket []byte) Option

func WithCheckBatch

func WithCheckBatch(batch int) Option

WithCheckBatch set batch check.

func WithClear

func WithClear(duration time.Duration) Option

WithClear timer clear invalid token, if <=0 not start timer

func WithDB

func WithDB(db *bolt.DB) Option

func WithFileMode

func WithFileMode(mode os.FileMode) Option

func WithFilename

func WithFilename(filename string) Option

func WithMaxSize

func WithMaxSize(maxSize int) Option

WithMaxSize maximum number of tokens saved, if <= 0 not limit

func WithRefresh

func WithRefresh(duration time.Duration) Option

WithRefresh set the valid time of refresh token, at least one second.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider a provider store data on local bolt database

func New

func New(opt ...Option) (provider *Provider, e error)

func (*Provider) Check

func (p *Provider) Check(ctx context.Context, token string) (e error)

Check return true if token not expired

func (*Provider) Clear

func (p *Provider) Clear() (e error)

func (*Provider) Close

func (p *Provider) Close() (e error)

Close provider

func (*Provider) Create

func (p *Provider) Create(ctx context.Context,
	access, refresh string,
	pair []sessionid.PairBytes,
) (e error)

Create new session

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, token string, keys []string) (err error)

Delete keys

func (*Provider) Destroy

func (p *Provider) Destroy(ctx context.Context, id string) (e error)

Destroy a session by id

func (*Provider) DestroyByToken

func (p *Provider) DestroyByToken(ctx context.Context, token string) (e error)

Destroy a session by token

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, token string, keys []string) (vals []sessionid.Value, e error)

Get key's value from token

func (*Provider) Keys

func (p *Provider) Keys(ctx context.Context, token string) (keys []string, e error)

Keys return all token's key

func (*Provider) Put

func (p *Provider) Put(ctx context.Context, token string, pair []sessionid.PairBytes) (err error)

Put key value for token

func (*Provider) Refresh

func (p *Provider) Refresh(ctx context.Context, access, refresh, newAccess, newRefresh string) (err error)

Refresh a new access token

Jump to

Keyboard shortcuts

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