PreSignV4Outposts presign the request for S3 on Outposts (service name s3-outposts).
(req http.Request, accessKeyID, secretAccessKey, sessionToken, location string, expires int64)
| 259 | |
| 260 | // PreSignV4Outposts presign the request for S3 on Outposts (service name s3-outposts). |
| 261 | func PreSignV4Outposts(req http.Request, accessKeyID, secretAccessKey, sessionToken, location string, expires int64) *http.Request { |
| 262 | // Presign is not needed for anonymous credentials. |
| 263 | if accessKeyID == "" || secretAccessKey == "" { |
| 264 | return &req |
| 265 | } |
| 266 | |
| 267 | t := time.Now().UTC() |
| 268 | credential := GetCredential(accessKeyID, location, t, ServiceTypeS3Outposts) |
| 269 | signedHeaders := getSignedHeaders(req, v4IgnoredHeaders) |
| 270 | query := req.URL.Query() |
| 271 | query.Set("X-Amz-Algorithm", signV4Algorithm) |
| 272 | query.Set("X-Amz-Date", t.Format(iso8601DateFormat)) |
| 273 | query.Set("X-Amz-Expires", strconv.FormatInt(expires, 10)) |
| 274 | query.Set("X-Amz-SignedHeaders", signedHeaders) |
| 275 | query.Set("X-Amz-Credential", credential) |
| 276 | if sessionToken != "" { |
| 277 | if v := req.Header.Get("x-amz-s3session-token"); v != "" { |
| 278 | query.Set("X-Amz-S3session-Token", sessionToken) |
| 279 | } else { |
| 280 | query.Set("X-Amz-Security-Token", sessionToken) |
| 281 | } |
| 282 | } |
| 283 | req.URL.RawQuery = query.Encode() |
| 284 | canonicalRequest := getCanonicalRequest(req, v4IgnoredHeaders, getHashedPayload(req)) |
| 285 | stringToSign := getStringToSignV4(t, location, canonicalRequest, ServiceTypeS3Outposts) |
| 286 | signingKey := getSigningKey(secretAccessKey, location, t, ServiceTypeS3Outposts) |
| 287 | signature := getSignature(signingKey, stringToSign) |
| 288 | req.URL.RawQuery += "&X-Amz-Signature=" + signature |
| 289 | return &req |
| 290 | } |
| 291 | |
| 292 | // PostPresignSignatureV4 - presigned signature for PostPolicy |
| 293 | // requests. |
no test coverage detected