MCPcopy
hub / github.com/minio/minio-go / PreSignV4Outposts

Function PreSignV4Outposts

pkg/signer/request-signature-v4.go:261–290  ·  view source on GitHub ↗

PreSignV4Outposts presign the request for S3 on Outposts (service name s3-outposts).

(req http.Request, accessKeyID, secretAccessKey, sessionToken, location string, expires int64)

Source from the content-addressed store, hash-verified

259
260// PreSignV4Outposts presign the request for S3 on Outposts (service name s3-outposts).
261func 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.

Callers 1

newRequestMethod · 0.92

Calls 9

GetCredentialFunction · 0.85
getSignedHeadersFunction · 0.85
getCanonicalRequestFunction · 0.85
getHashedPayloadFunction · 0.85
getStringToSignV4Function · 0.85
getSigningKeyFunction · 0.85
getSignatureFunction · 0.85
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected