Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

signature_v4

Signature Version 4


Description

Generates AWS Signature Version 4

Usage

signature_v4(
  secret = NULL,
  date = format(Sys.time(), "%Y%m%d"),
  region = NULL,
  service,
  string_to_sign,
  verbose = getOption("verbose", FALSE)
)

Arguments

secret

An AWS Secret Access Key. If NULL, it is retrieved using locate_credentials.

date

A character string containing a date in the form of “YYMMDD”. If missing, it is generated automatically using Sys.time.

region

A character string containing the AWS region for the request. If missing, “us-east-1” is assumed.

service

A character string containing the AWS service (e.g., “iam”, “host”, “ec2”).

string_to_sign

A character string containing the “String To Sign”, possibly returned by string_to_sign.

verbose

A logical indicating whether to be verbose.

Details

This function generates an AWS Signature Version 4 for authorizing API requests from its pre-formatted components. Users probably only need to use the signature_v4_auth function to generate signatures.

Author(s)

Thomas J. Leeper <thosjleeper@gmail.com>

References

See Also

Examples

## Not run: 
# From AWS documentation
# http://docs.aws.amazon.com/general/latest/gr/signature-v4-test-suite.html
StringToSign <- "AWS4-HMAC-SHA256
20110909T233600Z
20110909/us-east-1/host/aws4_request
e25f777ba161a0f1baf778a87faf057187cf5987f17953320e3ca399feb5f00d"

sig <- 
signature_v4(secret = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
             date = '20110909',
             region = 'us-east-1',
             service = 'host',
             string_to_sign = StringToSign)
identical(sig, "be7148d34ebccdc6423b19085378aa0bee970bdc61d144bd1a8c48c33079ab09")

# http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html
StringToSign <- "AWS4-HMAC-SHA256
20110909T233600Z
20110909/us-east-1/iam/aws4_request
3511de7e95d28ecd39e9513b642aee07e54f4941150d8df8bf94b328ef7e55e2"

sig <- 
signature_v4(secret = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
             date = '20110909',
             region = 'us-east-1',
             service = 'iam',
             string_to_sign = StringToSign)
identical(sig, "ced6826de92d2bdeed8f846f0bf508e8559e98e4b0199114b84c54174deb456c")

## End(Not run)

aws.signature

Amazon Web Services Request Signatures

v0.6.0
GPL (>= 2)
Authors
Thomas J. Leeper [aut] (<https://orcid.org/0000-0003-4097-6326>), Jonathan Stott [cre, aut], Mike Kaminsky [ctb]
Initial release
2020-06-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.