jwt

package
v0.0.0-...-1b39580 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(ttl time.Duration, payload interface{}, privateKey string) (string, error)

func DecodeToken

func DecodeToken(token, publicKey string) (interface{}, error)

Types

type JWTConfig

type JWTConfig struct {
	Access  Token `mapstructure:"accessToken"`
	Refresh Token `mapstructure:"refreshToken"`
}

type Token

type Token struct {
	PrivateKey string        `mapstructure:"privateKey"`
	PublicKey  string        `mapstructure:"publicKey"`
	ExpiresIn  time.Duration `mapstructure:"expiresIn"`
	MaxAge     int           `mapstructure:"maxAge"`
}

type TokenPair

type TokenPair struct {
	AccessToken  string `mapstructure:"accessToken"`
	RefreshToken string `mapstructure:"refreshToken"`
}

func GenerateTokenPair

func GenerateTokenPair(c JWTConfig, uid int64) (*TokenPair, error)

type UserClaims

type UserClaims struct {
	ID int64
}

func ValidateToken

func ValidateToken(token string, publicKey string) (*UserClaims, error)

Jump to

Keyboard shortcuts

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