jwt

package
v0.0.0-...-19bee3a Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bearer    = "Bearer "
	XTseToken = "X-Ts-Token"
	CookieKey = "ts-token"
)

Variables

This section is empty.

Functions

func EchoAuth

func EchoAuth() echo.MiddlewareFunc

func EchoEnforcer

func EchoEnforcer() echo.MiddlewareFunc

func EchoJwt

func EchoJwt(u IUser) echo.MiddlewareFunc

EchoAuth jwt注入鉴定

func GetAuthority

func GetAuthority(c echo.Context) (data string)

func ReadTimeout

func ReadTimeout() (timeout int64)

func SetTimeout

func SetTimeout(timeout int64) int64

func ValidToken

func ValidToken(u IUser, auth string) (user IUser, claims *TsClaims, err error)

ValidToken 验证Token

Types

type IUser

type IUser interface {
	New() IUser
	GetByID(tstype.UUID) error
	ID() tstype.UUID
	HasAdmin() bool
	OnlineExtend(*TsClaims) error
	OnlineCheck(*TsClaims, net.IP) error
}

type TsClaims

type TsClaims struct {
	jwt.StandardClaims
	UserID tstype.UUID `json:"usi,omitempty"`
}

func GenerateToken

func GenerateToken(id tstype.UUID, ct time.Time) (claims *TsClaims, t string)

GenerateToken 生成Token

func (*TsClaims) Extend

func (c *TsClaims) Extend(ct time.Time) *TsClaims

Extend 延期Token

func (*TsClaims) SignedString

func (c *TsClaims) SignedString() (t string)

Extend 延期Token

Jump to

Keyboard shortcuts

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