Documentation ¶
Overview ¶
Package aswign implments a simple library for signing HTTP requests made to Amazon AWS according to the specifications of the AWS Signature Version 4 Signing Process: http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html.
It exposes a Signer struct which can be used to set the necessary configuration variables:
signer := awsign.Signer{ Region: "us-east-1", Service: "iam", AccessKeyID: "<YOUR-ACCESS-KEY-ID>", AccessKeySecret: "<YOUR-ACCESS-KEY-SECRET>"}
Signer exposes a Sign method which accepts an http.Request object and an optional payload with the request body:
request, _ := http.NewRequest(http.MethodGet, "http://example.org", nil) payload = "Sample request body" signer.Sign(request, payload)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Signature ¶
func Signature(request *http.Request, payload string, timestamp time.Time, region, service, key string) string
Signature generates the request signature that has to be added to the Authorization header of a requests according to AWS documentation. This method can be used to manually generate the signature without using the Signer.Sign method.
Direct Callers of this method should handle the creation of the Authorization header manually.
Types ¶
type Signer ¶
Signer is a convenience mechanism for storing the configuration variables that are necessary for signing requests made to AWS, it allows users to instantiate it once and reuse it over several requests.
func (*Signer) Sign ¶
Sign accepts a request and an optional payload and signs the request by adding an Authorization header with the content required by Amazon AWS
http://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html