Revert "Merge branch 'canary' into kucherenko/canary"

This reverts commit 819822f30b, reversing
changes made to bda9b05134.
This commit is contained in:
Mauricio Siu
2025-03-02 00:26:59 -06:00
parent 819822f30b
commit e6cb6454db
639 changed files with 17202 additions and 82902 deletions

View File

@@ -1,39 +0,0 @@
package middleware
import (
"strings"
"github.com/gofiber/fiber/v2"
"github.com/mauriciogm/dokploy/apps/monitoring/config"
)
func AuthMiddleware() fiber.Handler {
return func(c *fiber.Ctx) error {
expectedToken := config.GetMetricsConfig().Server.Token
authHeader := c.Get("Authorization")
if authHeader == "" {
return c.Status(401).JSON(fiber.Map{
"error": "Authorization header is required",
})
}
// Check if the header starts with "Bearer "
if !strings.HasPrefix(authHeader, "Bearer ") {
return c.Status(401).JSON(fiber.Map{
"error": "Invalid authorization format. Use 'Bearer TOKEN'",
})
}
// Extract the token
token := strings.TrimPrefix(authHeader, "Bearer ")
if token != expectedToken {
return c.Status(401).JSON(fiber.Map{
"error": "Invalid token",
})
}
return c.Next()
}
}