jwtx

package
v0.0.0-...-8b4ee15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const (
	JwtAudience  = "aud"
	JwtExpire    = "exp"
	JwtId        = "jti"
	JwtIssueAt   = "iat"
	JwtIssuer    = "iss"
	JwtNotBefore = "nbf"
	JwtSubject   = "sub"
	JwtExt       = "ext"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JwtInstance

type JwtInstance struct {
	SecretKey []byte
}

func NewJwtInstance

func NewJwtInstance(SecretKey []byte) *JwtInstance

func (JwtInstance) CreateToken

func (that JwtInstance) CreateToken(options ...Option) (string, error)

GenerateJWT 生成JWT

func (JwtInstance) ParseToken

func (that JwtInstance) ParseToken(tokenString string) (*jwt.Token, error)

ParseToken 解析JWT

type Option

type Option func(jwt.MapClaims)

func WithAudience

func WithAudience(aud string) Option

func WithClaimExt

func WithClaimExt(key string, value interface{}) Option

func WithExpiresAt

func WithExpiresAt(exp int64) Option

func WithId

func WithId(jti string) Option

func WithIssuedAt

func WithIssuedAt(iat int64) Option

func WithIssuer

func WithIssuer(iss string) Option

func WithNotBefore

func WithNotBefore(nbf int64) Option

func WithSubject

func WithSubject(sub string) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL