This commit is contained in:
2026-07-28 09:58:33 +02:00
commit 22cbf10cc8
11 changed files with 639 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package auth
import (
"net/http"
"os"
)
import (
"github.com/gin-gonic/gin"
)
func AdminAuth() gin.HandlerFunc {
token := os.Getenv("ADMIN_TOKEN")
return func(c *gin.Context) {
if c.GetHeader("X-Admin-Token") != token {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"error": "Unauthorized",
})
return
}
c.Next()
}
}