feat: name change + bugfixes

This commit is contained in:
2026-10-09 22:55:02 +02:00
parent fb84e3384b
commit 95a25453df
8 changed files with 113 additions and 23 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
package auth
import (
"crypto/subtle"
"net/http"
"os"
)
@@ -15,7 +16,9 @@ func AdminAuth() gin.HandlerFunc {
return func(c *gin.Context) {
if c.GetHeader("X-Admin-Token") != token {
// Without a configured token every admin request is refused, never allowed
provided := c.GetHeader("X-Admin-Token")
if token == "" || subtle.ConstantTimeCompare([]byte(provided), []byte(token)) != 1 {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"error": "Unauthorized",
})