Documentation ¶
Index ¶
- Constants
- func NewToken(data JwtTokenData, secret string, opts ...Option) (string, error)
- func NewTokenWithExp(data JwtTokenData, key string) (string, error)
- func ParseToken[T any](tokenString string, secret string, target *T) error
- func Valid(value string, secret string) (bool, error)
- type JwtTokenData
- type JwtTokenPayload
- type Option
- type TokenOption
- type UserType
Constants ¶
View Source
const ( Admin = UserType("admin") Member = UserType("member") )
Variables ¶
This section is empty.
Functions ¶
func NewTokenWithExp ¶
func NewTokenWithExp(data JwtTokenData, key string) (string, error)
Types ¶
type JwtTokenData ¶ added in v1.3.20
type JwtTokenData struct { UserId int64 `json:"userId"` AccessToken string `json:"accessToken"` TenantId int64 `json:"tenantId"` UserType UserType `json:"userType"` }
func NewJwtTokenData ¶ added in v1.3.20
func NewJwtTokenData(token string) (*JwtTokenData, error)
type JwtTokenPayload ¶ added in v1.3.20
type JwtTokenPayload struct { Aud string `json:"aud"` Exp int64 `json:"exp"` Iss string `json:"iss"` Sub string `json:"sub"` Data JwtTokenData `json:"data"` }
type Option ¶
type Option func(*TokenOption)
func WithAudOption ¶
func WithExpOption ¶
func WithIssOption ¶
func WithSubOption ¶
type TokenOption ¶
type TokenOption struct { Exp *jwt.NumericDate Sub string Aud string Iss string }
Click to show internal directories.
Click to hide internal directories.