正在显示
4 个修改的文件
包含
44 行增加
和
1 行删除
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "oppmg/common/log" | 6 | "oppmg/common/log" |
| 7 | "oppmg/models" | 7 | "oppmg/models" |
| 8 | "oppmg/protocol" | 8 | "oppmg/protocol" |
| 9 | + "oppmg/utils/signature" | ||
| 9 | "strconv" | 10 | "strconv" |
| 10 | 11 | ||
| 11 | "github.com/astaxie/beego" | 12 | "github.com/astaxie/beego" |
| @@ -62,6 +63,11 @@ func (c *OpenApiController) GetChangeMedia() { | @@ -62,6 +63,11 @@ func (c *OpenApiController) GetChangeMedia() { | ||
| 62 | msg = protocol.BadRequestParam("1") | 63 | msg = protocol.BadRequestParam("1") |
| 63 | return | 64 | return |
| 64 | } | 65 | } |
| 66 | + if ok := signature.CheckSignaString(param.ChanceId, param.CheckSum); !ok { | ||
| 67 | + log.Error("签名check_sum比对失败") | ||
| 68 | + msg = protocol.BadRequestParam("1") | ||
| 69 | + return | ||
| 70 | + } | ||
| 65 | chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64) | 71 | chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64) |
| 66 | var ( | 72 | var ( |
| 67 | err error | 73 | err error |
| @@ -3,10 +3,12 @@ package audit | @@ -3,10 +3,12 @@ package audit | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + myconfig "oppmg/common/config" | ||
| 6 | "oppmg/common/log" | 7 | "oppmg/common/log" |
| 7 | "oppmg/models" | 8 | "oppmg/models" |
| 8 | "oppmg/protocol" | 9 | "oppmg/protocol" |
| 9 | "oppmg/utils/exceltool" | 10 | "oppmg/utils/exceltool" |
| 11 | + "oppmg/utils/signature" | ||
| 10 | "strconv" | 12 | "strconv" |
| 11 | "strings" | 13 | "strings" |
| 12 | 14 | ||
| @@ -116,7 +118,14 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | @@ -116,7 +118,14 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user | ||
| 116 | } | 118 | } |
| 117 | } | 119 | } |
| 118 | soureData[i]["soure_content"] = soureContentText.String() | 120 | soureData[i]["soure_content"] = soureContentText.String() |
| 119 | - soureData[i]["media"] = fmt.Sprintf("chance_id=%v&check_sum=%s", soureData[i]["id"], "xx") | 121 | + signString := signature.SignaString(fmt.Sprint(soureData[i]["id"])) |
| 122 | + var frontHost string | ||
| 123 | + if "prod" == myconfig.MConfig.ConfigName { | ||
| 124 | + frontHost = "https://web-open.fjmaimaimai.com/#/ability/opportunity/export-detail" | ||
| 125 | + } else { | ||
| 126 | + frontHost = "https://mmm-web-open-test.fjmaimaimai.com//#/ability/opportunity/export-detail" | ||
| 127 | + } | ||
| 128 | + soureData[i]["media"] = fmt.Sprintf("%s?chance_id=%v&check_sum=%s", frontHost, soureData[i]["id"], signString) | ||
| 120 | 129 | ||
| 121 | } | 130 | } |
| 122 | excelhead := []exceltool.ExcelHead{ | 131 | excelhead := []exceltool.ExcelHead{ |
| @@ -22,6 +22,7 @@ const ( | @@ -22,6 +22,7 @@ const ( | ||
| 22 | M_SYSTEM_ACHIEVEMENT string = "SYSTEM_ACHIEVEMENT" //成果管理 | 22 | M_SYSTEM_ACHIEVEMENT string = "SYSTEM_ACHIEVEMENT" //成果管理 |
| 23 | M_SYSTEM_RANK string = "SYSTEM_RANK" //排行榜配置管理 | 23 | M_SYSTEM_RANK string = "SYSTEM_RANK" //排行榜配置管理 |
| 24 | M_SYSTEM_CHECK_RESULT string = "SYSTEM_CHECK_RESULT" //机会筛选结果 | 24 | M_SYSTEM_CHECK_RESULT string = "SYSTEM_CHECK_RESULT" //机会筛选结果 |
| 25 | + M_SYSTEM_RESERVE_TYPE string = "SYSTEM_RESERVE_TYPE" //储备池分类 | ||
| 25 | ) | 26 | ) |
| 26 | 27 | ||
| 27 | type PermissionOptionObject interface { | 28 | type PermissionOptionObject interface { |
| 1 | package signature | 1 | package signature |
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "crypto/sha256" | ||
| 5 | + "encoding/hex" | ||
| 6 | + "strings" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +const ( | ||
| 10 | + mixtureBegin string = "v!(MmM" | ||
| 11 | + mixtureEnd string = "MmM)i^" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +func SignaString(s string) string { | ||
| 15 | + toSign := mixtureBegin + s + mixtureEnd | ||
| 16 | + sha256 := sha256.New() | ||
| 17 | + sha256.Write([]byte(toSign)) | ||
| 18 | + signHex := hex.EncodeToString(sha256.Sum(nil)) | ||
| 19 | + return signHex | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func CheckSignaString(s string, compared string) bool { | ||
| 23 | + signHex := SignaString(s) | ||
| 24 | + if strings.Compare(signHex, compared) == 0 { | ||
| 25 | + return true | ||
| 26 | + } | ||
| 27 | + return false | ||
| 28 | +} |
-
请 注册 或 登录 后发表评论