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

Types

type IUser

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

type TsClaims

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

func GenerateToken

func GenerateToken(id null.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