Documentation ¶
Index ¶
- Constants
- Variables
- func AdminAuth() web.MiddlewareFunc
- func Atom() web.MiddlewareFunc
- func Auth(ignore ...bool) web.MiddlewareFunc
- func AuthV2(must ...bool) web.MiddlewareFunc
- func GetAdminId(c echo.Context) (val int64)
- func GetAdminName(c echo.Context) string
- func GetCountryCode(c echo.Context) string
- func GetLang(c echo.Context) string
- func GetLoginType(c echo.Context) string
- func GetRole(c echo.Context) string
- func GetToken(c echo.Context) string
- func GetUID(c echo.Context) int64
- func ParseToken(r *http.Request) (token string, err error)
- func SetAuthServiceName(name string)
- type AtomInfo
- type JwtClaims
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 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 GetLoginType ¶
func GetLoginType(c echo.Context) string
func ParseToken ¶
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 位数不同设备不固定 }
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"` }
Click to show internal directories.
Click to hide internal directories.