jwt

package
v0.1.39 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenExpired return token expired err
	ErrTokenExpired = errors.New("app.err.TokenExpired")
	// ErrTokenWrongIssuer return wrong issuer err
	ErrTokenWrongIssuer = errors.New("app.err.TokenWrongIssuer")
	// ErrTokenWrongHeaderPrefix return wrong header prefix
	ErrTokenWrongHeaderPrefix = errors.New("app.err.TokenWrongHeaderPrefix")
	// ErrTokenWrongAuthorization return wrong authorization
	ErrTokenWrongAuthorization = errors.New("app.err.TokenWrongAuthorization")
)

Functions

func GenerateToken added in v0.0.50

func GenerateToken(app application.Application, claims jwt.Claims) (string, error)

GenerateToken generate tokens used for auth

func New

func New(app application.Application, config ...*Config) gin.HandlerFunc

New jwt middleware

Types

type Claims

type Claims struct {
	Userkey string `json:"userkey"`
	jwt.StandardClaims
}

Claims data to sign

type Config

type Config struct {
	HeaderName         string
	SecretKey          string
	JwtPrefix          string
	Issuer             string
	ExpireHour         int
	IsVerifyIssuer     bool
	IsVerifyExpireHour bool
	IsVerifySecretKey  bool
	Claims             jwt.Claims
	SuccessCallback    func(c *gin.Context, claim jwt.Claims)
	MethodWhiteList    []string
	PathWhiteList      []string
	SkipValidation     bool
}

Config jwt config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig default jwt config

type JWTVerifier

type JWTVerifier interface {
	Middleware() gin.HandlerFunc
	// contains filtered or unexported methods
}

JWTVerifier jwt verifier

type JWTVerifierImpl

type JWTVerifierImpl struct {
	// contains filtered or unexported fields
}

JWTVerifierImpl impl

func (*JWTVerifierImpl) Middleware

func (m *JWTVerifierImpl) Middleware() gin.HandlerFunc

Middleware jwt middleware

Jump to

Keyboard shortcuts

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