Documentation
¶
Index ¶
Constants ¶
View Source
const ( // UserContextKey 用户上下文键 UserContextKey contextKey = "auth_user" // TokenContextKey 令牌上下文键 TokenContextKey contextKey = "auth_token" )
Variables ¶
This section is empty.
Functions ¶
func GetAuthenticatedUser ¶
func GetAuthenticatedUser(ctx context.Context) (auth.Authenticatable, bool)
GetAuthenticatedUser 获取认证用户
Types ¶
type JWTMiddleware ¶
type JWTMiddleware struct {
// contains filtered or unexported fields
}
JWTMiddleware JWT认证中间件
func NewJWTMiddleware ¶
func NewJWTMiddleware(options Options) *JWTMiddleware
NewJWTMiddleware 创建新的JWT中间件
func (*JWTMiddleware) Middleware ¶
func (m *JWTMiddleware) Middleware() func(http.Handler) http.Handler
Middleware 返回HTTP中间件函数
func (*JWTMiddleware) RequirePermission ¶
RequirePermission 创建权限检查中间件
func (*JWTMiddleware) RequireRole ¶
RequireRole 创建角色检查中间件
Click to show internal directories.
Click to hide internal directories.