middleware

package
v0.0.0-...-b08fcc5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdminUID      = "admin_uid"
	AdminFullname = "admin_full_name"
)
View Source
const (
	UID         = "uid"
	Role        = "role"
	CountryCode = "country_code"
	LoginType   = "login_type"
	Token       = "token"
)
View Source
const AtomKEY = "header_key"
View Source
const JwtSecret = "9527a0213d5684m6364i1235n"

Variables

View Source
var DefaultAuthServiceName = "user"

Functions

func AdminAuth

func AdminAuth() web.MiddlewareFunc

AdminAuth 用户认证中间件

func Atom

func Atom() web.MiddlewareFunc

Atom 原子参数中间件

func Auth

func Auth(ignore ...bool) web.MiddlewareFunc

Auth 用户认证中间件 ignore 不是必须参数,不传默认强制验证,false 不强制验证

func AuthV2

func AuthV2(must ...bool) web.MiddlewareFunc

func GetAdminId

func GetAdminId(c echo.Context) (val int64)

func GetAdminName

func GetAdminName(c echo.Context) string

func GetCountryCode

func GetCountryCode(c echo.Context) string

func GetLang

func GetLang(c echo.Context) string

func GetLoginType

func GetLoginType(c echo.Context) string

func GetRole

func GetRole(c echo.Context) string

func GetToken

func GetToken(c echo.Context) string

func GetUID

func GetUID(c echo.Context) int64

GetUID 获取 UID

func ParseToken

func ParseToken(r *http.Request) (token string, err error)

ParseToken 解析 token Extract bearer token from Authorization header Uses PostExtractionFilter to strip "Bearer " prefix from header

func SetAuthServiceName

func SetAuthServiceName(name string)

Types

type AtomInfo

type AtomInfo struct {
	Platform          string `json:"x-pt"` // 平台
	DeviceFingerprint string `json:"x-df"` // 设备指纹
	PackageName       string `json:"x-pn"` // 应用标识
	SystemVersion     string `json:"x-os"` //手机系统版本
	Language          string `json:"x-cl"` // 设备语言
	DeviceName        string `json:"x-dn"` // 设备名 base64编码值
	Network           string `json:"x-nt"` // 网络类型
	Version           string `json:"x-cv"` // app 版本
	Channel           string `json:"x-cn"` // 当前app投放渠道 OPPO、Vivo 、三星、小米、苹果、一加、华为、TECNO
	Appcode           string `json:"x-cd"` // 当前app标识码
	DeviceToken       string `json:"x-dt"` // 设备token 位数不同设备不固定
}

func GetAtom

func GetAtom(c echo.Context) (atomInfo *AtomInfo, err error)

GetAtom 获取header头原子参数

type JwtClaims

type JwtClaims struct {
	Id             int64  `json:"id"`
	UserType       int    `json:"user_type"`
	Username       string `json:"username"`
	Country        string `json:"country"`
	Fullname       string `json:"fullname"`
	IsLogin        int    `json:"is_login"`
	Email          string `json:"email"`
	RoleId         int    `json:"role_id"`
	Addtime        int    `json:"addtime"`
	LastLoginTime  int    `json:"last_login_time"`
	LastLoginIp    int    `json:"last_login_ip"`
	LastUpdateTime int    `json:"last_update_time"`
}

Jump to

Keyboard shortcuts

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