xjwt

package
v0.0.0-...-434fc75 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(claims Claims) (string, error)

New 生成 JWT

func NewAccess

func NewAccess(user *model.User) (string, error)

func NewRefresh

func NewRefresh(user *model.User) (string, error)

Types

type Claims

type Claims struct {
	UserID    int64     `json:"user_id"`
	Username  string    `json:"username"`
	TokenType TokenType `json:"token_type"`
	jwt.StandardClaims
}

func Validate

func Validate(t string) (*Claims, error)

func ValidateAccess

func ValidateAccess(t string) (*Claims, error)

func ValidateRefresh

func ValidateRefresh(t string) (*Claims, error)

type TokenType

type TokenType uint8
const (
	Refresh TokenType = iota
	Access
)

Jump to

Keyboard shortcuts

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