蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 regels
657 B

  1. package mw
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/e"
  5. "applet/app/lib/aes"
  6. "applet/app/lib/aes/md"
  7. "applet/app/utils"
  8. "errors"
  9. "fmt"
  10. "github.com/gin-gonic/gin"
  11. )
  12. // CheckSign is 中间件 用来检查签名
  13. func CheckSign(c *gin.Context) {
  14. if !(utils.GenerateMD5Hash(c.Request.Host) == md.ConvenientKeyForTest || (c.GetHeader("is_check") == "false" && !cfg.Prd)) {
  15. err := aes.CheckSign(c)
  16. if err != nil {
  17. if cfg.Prd {
  18. fmt.Println("签名问题:" + err.Error())
  19. e.OutErr(c, 400, errors.New("请求失败~~"))
  20. } else {
  21. e.OutErr(c, 400, "验签失败: "+err.Error())
  22. }
  23. return
  24. }
  25. c.Next()
  26. c.Set("is_sign", true)
  27. }
  28. }