Update
This commit is contained in:
parent
7adf3b9512
commit
380fe41d1a
@ -4,20 +4,20 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
jwtMiddleware "github.com/gofiber/jwt/v2"
|
||||
jwt "github.com/gofiber/jwt/v2"
|
||||
)
|
||||
|
||||
// JWTProtected func for specify routes group with JWT authentication.
|
||||
// See: https://github.com/gofiber/jwt
|
||||
func JWTProtected() func(*fiber.Ctx) error {
|
||||
// Create config for JWT authentication middleware.
|
||||
config := jwtMiddleware.Config{
|
||||
config := jwt.Config{
|
||||
SigningKey: []byte(os.Getenv("JWT_SECRET_KEY")),
|
||||
ContextKey: "jwt", // used in private routes
|
||||
ErrorHandler: jwtError,
|
||||
}
|
||||
|
||||
return jwtMiddleware.New(config)
|
||||
return jwt.New(config)
|
||||
}
|
||||
|
||||
func jwtError(c *fiber.Ctx, err error) error {
|
||||
|
Loading…
Reference in New Issue
Block a user