signature_v4: Signature Version 4

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/v4.R

Description

Generates AWS Signature Version 4

Usage

1
2
3
signature_v4(secret = Sys.getenv("AWS_SECRET_ACCESS_KEY"),
  date = format(Sys.time(), "%Y%m%d"),
  region = Sys.getenv("AWS_DEFAULT_REGION"), service, string_to_sign)

Arguments

secret

An AWS Secret Access Key. If missing, it is retrieved using Sys.getenv("AWS_SECRET_ACCESS_KEY").

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. By default, the “us-east-1” region.

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.

Details

This function generates an AWS Signature Version 4 for authorizing API requests.

Author(s)

Thomas J. Leeper <[email protected]>

References

AWS General Reference: Signature Version 4 Signing Process

AWS General Reference: Examples of How to Derive a Version 4 Signing Key

Amazon S3 API Reference: Authenticating Requests (AWS Signature Version 4)

See Also

signature_v2_auth, use_credentials

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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")

zhangxing-love/qingstor.signature documentation built on May 23, 2017, 6:43 a.m.