cloudyr / aws.signature

Compare e768a63 ... +5 ... e78eddb

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -8,6 +8,7 @@
Loading
8 8
#' @param query_args A named list of character strings containing the query string values (if any) used in the API request, passed to \code{\link{canonical_request}}.
9 9
#' @param canonical_headers A named list of character strings containing the headers used in the request.
10 10
#' @param request_body The body of the HTTP request.
11 +
#' @param signed_body Should the body be signed
11 12
#' @template key
12 13
#' @template secret
13 14
#' @param session_token Optionally, an AWS Security Token Service (STS) temporary Session Token. This is added automatically as a header to \code{canonical_headers}. See \code{\link{locate_credentials}}.
@@ -72,6 +73,7 @@
Loading
72 73
  query_args = list(),
73 74
  canonical_headers, # named list
74 75
  request_body,
76 +
  signed_body = FALSE,
75 77
  key = NULL,
76 78
  secret = NULL,
77 79
  session_token = NULL,
@@ -121,7 +123,8 @@
Loading
121 123
                           canonical_uri = action,
122 124
                           query_args = query_args,
123 125
                           canonical_headers = canonical_headers,
124 -
                           request_body = request_body)
126 +
                           request_body = request_body,
127 +
                           signed_body = signed_body)
125 128
    
126 129
    # String To Sign
127 130
    S <- string_to_sign(algorithm = algorithm,
@@ -144,7 +147,7 @@
Loading
144 147
                       paste(paste0("Credential=", credential),
145 148
                             paste0("SignedHeaders=", R$headers),
146 149
                             paste0("Signature=", V4),
147 -
                             sep = ", "))
150 +
                             sep = ","))
148 151
    structure(list(Algorithm = algorithm,
149 152
                   Credential = credential,
150 153
                   Date = date,

@@ -403,10 +403,9 @@
Loading
403 403
                                              default_region = default_region,
404 404
                                              verbose = verbose,
405 405
                                              try_ec2 = TRUE)
406 +
          # early return
407 +
          return(list(key = key, secret = secret, session_token = session_token, region = region))
406 408
        }
407 -
        
408 -
        # early return
409 -
        return(list(key = key, secret = secret, session_token = session_token, region = region))
410 409
    }
411 410
    return(NULL)
412 411
}

@@ -5,6 +5,7 @@
Loading
5 5
#' @param query_args A named list of character strings containing the query string values (if any) used in the API request.
6 6
#' @param canonical_headers A named list of character strings containing the headers used in the request.
7 7
#' @param request_body The body of the HTTP request, or a filename. If a filename, hashing is performed on the file without reading it into memory.
8 +
#' @param signed_body Sign the body request and add the correct header (x-amz-content-sha256) to the list of headers
8 9
#' @details This function creates a \dQuote{Canonical Request}, which is part of the Signature Version 4. Users probably only need to use the \code{\link{signature_v4_auth}} function to generate signatures.
9 10
#' @return A list containing
10 11
#' @author Thomas J. Leeper <thosjleeper@gmail.com>
@@ -41,7 +42,8 @@
Loading
41 42
         canonical_uri = "",
42 43
         query_args = list(),
43 44
         canonical_headers,
44 -
         request_body = ""
45 +
         request_body = "",
46 +
         signed_body = FALSE
45 47
         ) {
46 48
    if (is.character(request_body) && file.exists(request_body)) {
47 49
        body_hash <- tolower(digest::digest(request_body, file = TRUE, algo = "sha256", serialize = FALSE))
@@ -54,6 +56,10 @@
Loading
54 56
    Sys.setlocale(category = "LC_COLLATE", locale = "C")
55 57
    on.exit(Sys.setlocale(category = "LC_COLLATE", locale = lc))
56 58
    
59 +
    if (isTRUE(signed_body)) {
60 +
        canonical_headers[['x-amz-content-sha256']] = body_hash
61 +
    }
62 +
    
57 63
    names(canonical_headers) <- tolower(names(canonical_headers))
58 64
    canonical_headers <- canonical_headers[order(names(canonical_headers))]
59 65
    # trim leading, trailing, and all non-quoted duplicated spaces

Learn more Showing 2 files with coverage changes found.

Changes in R/canonical_request.R
-1
+1
Loading file...
Changes in R/locate_credentials.R
-11
+11
Loading file...
Files Coverage
R +2.97% 70.94%
Project Totals (10 files) 70.94%
Loading