token

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotParsed = fmt.Errorf("token: not parsed")

Functions

func GetExpire

func GetExpire() time.Duration

func GetID

func GetID(ctx context.Context) string

func GetIssuedAt

func GetIssuedAt(ctx context.Context) int64

func GetIssuer

func GetIssuer(ctx context.Context) string

func GetUserId

func GetUserId(ctx context.Context) string

func SetExpire

func SetExpire(d time.Duration)

Types

type Extra

type Extra map[string]interface{}

func GetExtra

func GetExtra(ctx context.Context) Extra

type Option

type Option func(t *Token)

func WithExtra

func WithExtra(extra Extra) Option

func WithID

func WithID(id string) Option

type Token

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

func FromContext

func FromContext(ctx context.Context) (*Token, error)

func MustFromContext

func MustFromContext(ctx context.Context) *Token

func New

func New(iss, uid string, iat int64, opts ...Option) *Token

func Parse

func Parse(s string) (*Token, error)

func (*Token) GetExtra

func (t *Token) GetExtra() Extra

func (*Token) GetID

func (t *Token) GetID() string

func (*Token) GetIssuedAt

func (t *Token) GetIssuedAt() int64

func (*Token) GetIssuer

func (t *Token) GetIssuer() string

func (*Token) GetUserId

func (t *Token) GetUserId() string

func (*Token) IsExpired

func (t *Token) IsExpired() bool

func (*Token) Refresh

func (t *Token) Refresh() *Token

func (*Token) Sign

func (t *Token) Sign() (string, error)

func (*Token) SignString

func (t *Token) SignString() string

func (*Token) WithContext

func (t *Token) WithContext(ctx ...context.Context) context.Context

Jump to

Keyboard shortcuts

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