wallet/pkg/rest/auth_middleware.go
Anton Nesterov f1bc53ce2a
[init]
2024-08-31 17:00:14 +02:00

22 lines
411 B
Go

package rest
import (
"net/http"
"custodial/pkg/locker"
"github.com/gin-gonic/gin"
)
func AuthMiddleware() gin.HandlerFunc {
locker.Settings()
apiMasterKey := locker.GetPrivateEnv("API_MASTER_KEY")
return func(c *gin.Context) {
if c.Request.Header.Get("Authorization") != apiMasterKey {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
return
}
c.Next()
}
}