Documentation ¶
Index ¶
- Constants
- func AdminHandle(next http.HandlerFunc) http.HandlerFunc
- func CanAccess(next http.HandlerFunc, check func(r *http.Request) (*CanAccessResp, error)) http.HandlerFunc
- func GetJwtTokenDataFromCtx(ctx context.Context) (*jwtx.JwtTokenData, *errx.Error)
- func GetTokenFromRequest(r *http.Request) (string, *errx.Error)
- func GetUserContextFromCtx(ctx context.Context) (*sessionx.UserContext, *errx.Error)
- func WithJwtTokenContext(ctx context.Context, r *http.Request, secret string) (*http.Request, string, *errx.Error)
- func WithTokenDataContext(ctx context.Context, r *http.Request, data jwtx.JwtTokenData) (*http.Request, *errx.Error)
- type CanAccessResp
- type RpcTokenKey
- type UserContextKey
Constants ¶
View Source
const ( JwtTokenDataKey = UserContextKey("JwtTokenData") AdminUserContextKey = UserContextKey("UserContext") )
View Source
const ( REFESH_TOKEN_EXPIRED_AT = "refresh-token-expired-at" TOKEN_EXPIRED_AT = "access-token-expired-at" )
Variables ¶
This section is empty.
Functions ¶
func AdminHandle ¶ added in v1.3.40
func AdminHandle(next http.HandlerFunc) http.HandlerFunc
透传给Rpc authorization 认证token
func CanAccess ¶ added in v1.3.29
func CanAccess(next http.HandlerFunc, check func(r *http.Request) (*CanAccessResp, error)) http.HandlerFunc
检查是否可以访问资源
func GetJwtTokenDataFromCtx ¶ added in v1.3.35
从ctx获取用户请求内容
func GetTokenFromRequest ¶
读取Request Header Authorization
func GetUserContextFromCtx ¶ added in v1.3.39
获取后台用户上下文
Types ¶
type CanAccessResp ¶ added in v1.3.41
type CanAccessResp struct { Access bool TokenExpiredAt int64 RefreshTokenExpiredAt int64 AccessToken string TenantId int64 TenantCode string UserId int64 UserCode string UserName string Mobile string Mail string JwtToken string PermissionGroup string // 权限组 PermissionCode string // 权限码 TraceId string SpanId string }
type RpcTokenKey ¶ added in v1.3.37
type RpcTokenKey string
func NewRpcTokenKey ¶ added in v1.3.37
func NewRpcTokenKey() RpcTokenKey
type UserContextKey ¶
type UserContextKey string
Click to show internal directories.
Click to hide internal directories.