This commit is contained in:
Piotr Biernat 2023-05-22 21:58:38 +02:00
parent 7adf3b9512
commit 380fe41d1a

View File

@ -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 {