Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ginjwt
✓ github.com/appleboy/gin-jwt
Sets up JWT authentication with Gin.
package main
import (
"github.com/appleboy/gin-jwt"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
authMiddleware, _ := ginjwt.New(&ginjwt.GinJWTMiddleware{
Realm: "test zone",
Key: []byte("secret key"),
Timeout: time.Hour,
MaxRefresh: time.Hour,
Authenticator: func(userId string, password string, c *gin.Context) (string, bool) {
if userId == "admin" && password == "admin" {
return userId, true
}
return userId, false
},
})
r.POST("/login", authMiddleware.LoginHandler)
r.Run()
}
Upgrade
Version history
2.5.0+incompatiblelatest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.