token

package
v0.0.0-...-dc61bab Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PrivateKey string        `mapstructure:"privateKey"`
	PublicKey  string        `mapstructure:"publicKey"`
	TTL        time.Duration `mapstructure:"ttl"`
}

type JWTCustomClaims

type JWTCustomClaims struct {
	UID string `json:"uid"`
	jwt.StandardClaims
}

func (*JWTCustomClaims) MarshalLogObject

func (c *JWTCustomClaims) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (*JWTCustomClaims) Valid

func (c *JWTCustomClaims) Valid() error

type JWTService

type JWTService interface {
	CreateToken(id string) (jwt, uid string, err error)
	ParseToken(jwt string) (*JWTCustomClaims, error)
	TokenTTL() time.Duration
}

func NewJWTService

func NewJWTService(cfg Config) (JWTService, error)

type Option

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

Option configures a TokensService.

func Preset

func Preset(options ...Option) Option

Preset turns a list of Option instances into an Option

func SetConfig

func SetConfig(cfg Config) Option

func SetPrivateKey

func SetPrivateKey(privateKey string) Option

func SetPublicKey

func SetPublicKey(publicKey string) Option

func SetTTL

func SetTTL(ttl time.Duration) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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