package middleware import ( "eta/eta_bridge/controller/resp" "eta/eta_bridge/global" "eta/eta_bridge/utils" "github.com/gin-gonic/gin" ) func Token() gin.HandlerFunc { return func(c *gin.Context) { token := c.Request.Header.Get("Authorization") if token == "" { token = c.DefaultQuery("authorization", "") if token == "" { token = c.DefaultQuery("Authorization", "") } } if token == "" { resp.TokenError(nil, "非法访问", "非法访问", c) c.Abort() return } if token != utils.CrmEtaAuthorization { resp.TokenError(nil, "非法访问", "非法访问", c) c.Abort() return } c.Next() } } func InternalToken() gin.HandlerFunc { return func(c *gin.Context) { token := c.Request.Header.Get("Authorization") if token == "" { token = c.DefaultQuery("authorization", "") if token == "" { token = c.DefaultQuery("Authorization", "") } } if token == "" { resp.TokenError(nil, "非法访问", "非法访问", c) c.Abort() return } checkToken := utils.MD5(global.CONFIG.Serve.AppNameEn + global.CONFIG.Serve.Md5Key) if token != checkToken { resp.TokenError(nil, "非法访问", "非法访问", c) c.Abort() return } c.Next() } }