wallet/pkg/rest/auth_middleware.go

21 lines
438 B
Go
Raw Normal View History

2024-08-31 14:46:20 +00:00
package rest
import (
"net/http"
"git.pspay.io/crypto-stories/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()
}
}