Documentation ¶
Overview ¶
Package awsv4 implements signing for AWS V4 signer with static credentials, and is based on and modified from code in the package aws-sdk-go. The modifications remove non-static credentials, support for non-sts services, and the options for v4.Signer. They also reduce the number of non-Go library dependencies.
Index ¶
Constants ¶
const StaticProviderName = "StaticProvider"
StaticProviderName provides a name of Static provider
Variables ¶
var ( // ErrStaticCredentialsEmpty is emitted when static credentials are empty. ErrStaticCredentialsEmpty = errors.New("EmptyStaticCreds: static credentials are empty") )
Functions ¶
func EscapePath ¶
EscapePath escapes part of a URL path in Amazon style
Types ¶
type Signer ¶
type Signer struct {
Credentials *StaticProvider
}
Signer applies AWS v4 signing to given request. Use this to sign requests that need to be signed with AWS V4 Signatures.
func NewSigner ¶
func NewSigner(credentials *StaticProvider) *Signer
NewSigner returns a Signer pointer configured with the credentials and optional option values provided. If not options are provided the Signer will use its default configuration.
func (Signer) Sign ¶
func (v4 Signer) Sign(r *http.Request, body io.ReadSeeker, service, region string, signTime time.Time) (http.Header, error)
Sign signs AWS v4 requests with the provided body, service name, region the request is made to, and time the request is signed at. The signTime allows you to specify that a request is signed for the future, and cannot be used until then.
Returns a list of HTTP headers that were included in the signature or an error if signing the request failed. Generally for signed requests this value is not needed as the full request context will be captured by the http.Request value. It is included for reference though.
Sign will set the request's Body to be the `body` parameter passed in. If the body is not already an io.ReadCloser, it will be wrapped within one. If a `nil` body parameter passed to Sign, the request's Body field will be also set to nil. Its important to note that this functionality will not change the request's ContentLength of the request.
Sign differs from Presign in that it will sign the request using HTTP header values. This type of signing is intended for http.Request values that will not be shared, or are shared in a way the header values on the request will not be lost.
The requests body is an io.ReadSeeker so the SHA256 of the body can be generated. To bypass the signer computing the hash you can set the "X-Amz-Content-Sha256" header with a precomputed value. The signer will only compute the hash if the request header value is empty.
type StaticProvider ¶
type StaticProvider struct {
Value
}
A StaticProvider is a set of credentials which are set programmatically, and will never expire.
func (*StaticProvider) Retrieve ¶
func (s *StaticProvider) Retrieve() (Value, error)
Retrieve returns the credentials or error if the credentials are invalid.