Documentation
¶
Index ¶
- Constants
- func GetTokenDataFromCtx(ctx context.Context) (*jwtx.JwtTokenData, error)
- func GetTokenFromRequest(r *http.Request) (string, error)
- func IsAuthorize(next http.HandlerFunc, canAccess func(r *http.Request) (*CanAccess, error)) http.HandlerFunc
- func WithRawTokenDataContext(ctx context.Context, r *http.Request, data jwtx.JwtTokenData) (*http.Request, error)
- func WithRpcTokenContext(ctx context.Context, r *http.Request) (*http.Request, error)
- func WithTokenContext(ctx context.Context, r *http.Request, secret string) (*http.Request, string, error)
- type CanAccess
- type TokenKey
- type UserContextKey
Constants ¶
View Source
const ( REFESH_TOKEN_EXPIRED_AT = "refresh-token-expired-at" TOKEN_EXPIRED_AT = "access-token-expired-at" )
View Source
const (
UserContext = UserContextKey("UserContext")
)
Variables ¶
This section is empty.
Functions ¶
func GetTokenDataFromCtx ¶
func GetTokenDataFromCtx(ctx context.Context) (*jwtx.JwtTokenData, error)
从ctx获取用户请求内容
func GetTokenFromRequest ¶
读取Request Header Authorization
func IsAuthorize ¶ added in v1.3.29
func IsAuthorize(next http.HandlerFunc, canAccess func(r *http.Request) (*CanAccess, error)) http.HandlerFunc
func WithRawTokenDataContext ¶ added in v1.3.32
func WithRpcTokenContext ¶ added in v1.3.32
透传给Rpc authorization 认证token
Types ¶
type TokenKey ¶ added in v1.3.32
type TokenKey string
func NewTokenKey ¶ added in v1.3.32
func NewTokenKey() TokenKey
type UserContextKey ¶
type UserContextKey string
Click to show internal directories.
Click to hide internal directories.