蛋蛋星球-客户端
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.

mw_check_sign.go 601 B

6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
6 days ago
12345678910111213141516171819202122232425262728
  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. "github.com/gin-gonic/gin"
  10. )
  11. // CheckSign is 中间件 用来检查签名
  12. func CheckSign(c *gin.Context) {
  13. if !(utils.GenerateMD5Hash(c.Request.Host) == md.ConvenientKeyForTest || (c.GetHeader("is_check") == "false" && !cfg.Prd)) {
  14. err := aes.CheckSign(c)
  15. if err != nil {
  16. if cfg.Prd {
  17. e.OutErr(c, 400, errors.New("请求失败~~"))
  18. } else {
  19. e.OutErr(c, 400, "验签失败: "+err.Error())
  20. }
  21. return
  22. }
  23. c.Next()
  24. c.Set("is_sign", true)
  25. }
  26. }