Feat: auth middleware for complex request

This commit is contained in:
HFO4
2019-12-24 11:42:23 +08:00
parent 90827b2441
commit f8c8604cda
7 changed files with 124 additions and 16 deletions

View File

@@ -15,7 +15,8 @@ type HMACAuth struct {
SecretKey []byte
}
// Sign 对给定Body生成expires后失效的签名
// Sign 对给定Body生成expires后失效的签名expires为过期时间戳
// 填写为0表示不限制有效期
func (auth HMACAuth) Sign(body string, expires int64) string {
h := hmac.New(sha256.New, auth.SecretKey)
expireTimeStamp := strconv.FormatInt(expires, 10)