Initial commit

This commit is contained in:
Carl Pearson
2025-05-30 05:35:27 -06:00
commit fa7c416f66
16 changed files with 1080 additions and 0 deletions

23
handlers/middleware.go Normal file
View File

@@ -0,0 +1,23 @@
package handlers
import (
"net/http"
"github.com/labstack/echo/v4"
"git.sr.ht/~cwpearson/replicate-jump-server/config"
)
// AuthMiddleware validates the bearer token
func AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
auth := c.Request().Header.Get("Authorization")
expectedAuth := "Bearer " + config.Bearer()
if auth != expectedAuth {
return echo.NewHTTPError(http.StatusUnauthorized, "Invalid or missing bearer token")
}
return next(c)
}
}