代码拉取完成,页面将自动刷新
// Thanks to Michael Vierling for contributing sign3.go
package awsauth
import (
"encoding/base64"
"net/http"
"time"
)
func stringToSignV3(req *http.Request) string {
// TASK 1. http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RESTAuthentication.html#StringToSign
return req.Header.Get("Date") + req.Header.Get("x-amz-nonce")
}
func signatureV3(stringToSign string, keys Credentials) string {
// TASK 2. http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RESTAuthentication.html#Signature
hash := hmacSHA256([]byte(keys.SecretAccessKey), stringToSign)
return base64.StdEncoding.EncodeToString(hash)
}
func buildAuthHeaderV3(signature string, keys Credentials) string {
// TASK 3. http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/RESTAuthentication.html#AuthorizationHeader
return "AWS3-HTTPS AWSAccessKeyId=" + keys.AccessKeyID +
", Algorithm=HmacSHA256" +
", Signature=" + signature
}
func prepareRequestV3(req *http.Request) *http.Request {
ts := timestampV3()
necessaryDefaults := map[string]string{
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"x-amz-date": ts,
"Date": ts,
"x-amz-nonce": "",
}
for header, value := range necessaryDefaults {
if req.Header.Get(header) == "" {
req.Header.Set(header, value)
}
}
if req.URL.Path == "" {
req.URL.Path += "/"
}
return req
}
func timestampV3() string {
return now().Format(timeFormatV3)
}
const timeFormatV3 = time.RFC1123
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。