Documentation ¶
Index ¶
- Constants
- Variables
- func CasbinHandler() gin.HandlerFunc
- func CompareRedisToken(userInfo UserInfo, tokenStr string) bool
- func Cors() gin.HandlerFunc
- func CreateToken(userInfo UserInfo) (string, error)
- func GetTokenRedisKey(userId int64, userName string) string
- func JwtAuth() gin.HandlerFunc
- func OperationRecord() gin.HandlerFunc
- type CustomClaims
- type OperationRecordData
- type UserInfo
- type UserToRoles
Constants ¶
View Source
const TokenRedisKeyPrefix = "LoginToke:"
Variables ¶
Functions ¶
func CasbinHandler ¶
func CasbinHandler() gin.HandlerFunc
CasbinHandler
@Description: API访问权限Casbin鉴权 @return gin.HandlerFunc
func CompareRedisToken ¶
CompareRedisToken 当前Token与Redis记录Token匹配
func GetTokenRedisKey ¶
GetTokenRedisKey 获取token缓存Key
func OperationRecord ¶
func OperationRecord() gin.HandlerFunc
Types ¶
type CustomClaims ¶
type CustomClaims struct { UserInfo UserInfo // 用户登录信息 jwt.StandardClaims // 标准载荷信息 }
CustomClaims
@Description: 自定义Token内容结构
func ParseToken ¶
func ParseToken(tokenStr string) (*CustomClaims, error)
ParseToken token解析方法,返回含有用户信息的数据结构
type OperationRecordData ¶
type OperationRecordData struct { Id int64 `json:"id" form:"id" gorm:"column:id;primary"` Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"` // 请求ip CreatedTime time.Time `json:"createdTime" from:"createdTime" gorm:"column:created_time;comment:创建时间"` // 记录创建时间 Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"` // 请求方法 Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"` // 请求路径 Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"` // 请求状态 Latency int64 `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟 Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"` // 代理 ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"` // 错误信息 Body string `json:"body" form:"body" gorm:"type:longtext;column:body;comment:请求Body"` // 请求Body Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"` // 响应Body UserID int64 `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"` // 用户id }
OperationRecordData
@Description: 数据记录结构
func (OperationRecordData) TableName ¶
func (OperationRecordData) TableName() string
type UserInfo ¶
type UserInfo struct { AccountId int64 `json:"accountId"` // 用户ID DingtalkId string `json:"dingtalkId"` // 钉钉ID UserName string `json:"userName"` // 用户名称 NickName string `json:"nickName"` // 用户昵称 RoleId string `json:"roleId"` // 角色ID }
UserInfo
@Description: 用户登录信息
type UserToRoles ¶
type UserToRoles struct { UserId int64 `json:"userId" gorm:"account_myuser_id"` RoleId string `json:"roleId" gorm:"authority_role_authority_id"` }
UserToRoles 临时角色-用户对应表
func (UserToRoles) TableName ¶
func (UserToRoles) TableName() string
Click to show internal directories.
Click to hide internal directories.