Documentation
¶
Overview ¶
Package jwtx 提供与传输无关的 JWT 签发和解析, 供 server 鉴权中间件和应用侧共用同一套语义。
Index ¶
- type Claims
- func (c Claims) Decode(target any) error
- func (c Claims) GetAudience() (jwt.ClaimStrings, error)
- func (c Claims) GetExpirationTime() (*jwt.NumericDate, error)
- func (c Claims) GetIssuedAt() (*jwt.NumericDate, error)
- func (c Claims) GetIssuer() (string, error)
- func (c Claims) GetNotBefore() (*jwt.NumericDate, error)
- func (c Claims) GetSubject() (string, error)
- func (c Claims) MarshalJSON() ([]byte, error)
- func (c *Claims) UnmarshalJSON(data []byte) error
- type Codec
- type MapClaims
- type Parser
- type Signer
- type Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶ added in v1.4.1
Claims 是带常用标准声明和额外声明的 JWT 载荷:jti/sub/iat/exp 为独立字段, 其余声明与标准声明同级扁平存放在 Extra 中,可直接用于 Sign 和 Parse。
func (Claims) GetAudience ¶ added in v1.4.1
func (c Claims) GetAudience() (jwt.ClaimStrings, error)
func (Claims) GetExpirationTime ¶ added in v1.4.1
func (c Claims) GetExpirationTime() (*jwt.NumericDate, error)
func (Claims) GetIssuedAt ¶ added in v1.4.1
func (c Claims) GetIssuedAt() (*jwt.NumericDate, error)
func (Claims) GetNotBefore ¶ added in v1.4.1
func (c Claims) GetNotBefore() (*jwt.NumericDate, error)
func (Claims) GetSubject ¶ added in v1.4.1
func (Claims) MarshalJSON ¶ added in v1.4.1
func (*Claims) UnmarshalJSON ¶ added in v1.4.1
type Codec ¶
Codec 同时提供签发和解析能力,对应同一算法和密钥。
type Time ¶ added in v1.4.1
Time 表示 JWT 声明中的时间,payload 内以秒级时间戳编解码。
func (Time) MarshalJSON ¶ added in v1.4.1
func (*Time) UnmarshalJSON ¶ added in v1.4.1
Click to show internal directories.
Click to hide internal directories.