provide a gin gonic example
MushiTheMoshi opened this issue · 2 comments
MushiTheMoshi commented
provide a gin gonic example
FlorianRuen commented
Any news for this issue ?
I tried something that works but for the entire API, not route by route because the param is http.Handler instead of gin.Handler
jwtMiddleware := authMiddleware.InitMiddleWare()
router.Use(adapter.Wrap(jwtMiddleware.CheckJWT))
func (ctrl authMiddleware) InitMiddleWare() *jwtmiddleware.JWTMiddleware {
issuerURL, err := url.Parse("DOMAIN")
if err != nil {
log.Fatalf("failed to parse the issuer url: %v", err)
}
provider := jwks.NewCachingProvider(issuerURL, 5*time.Minute)
// Set up the validator.
jwtValidator, err := validator.New(
provider.KeyFunc,
validator.RS256,
issuerURL.String(),
[]string{"AUDIENCE"},
)
if err != nil {
log.Fatalf("failed to set up the validator: %v", err)
}
// Set up the middleware.
return jwtmiddleware.New(jwtValidator.ValidateToken)
}
sergiught commented
Hey @MushiTheMoshi , @FlorianRuen 👋🏻 this is now available within https://github.com/auth0/go-jwt-middleware/tree/v2.1.0/examples/gin-example. Thanks for your patience!