hwscloud

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2019 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasicDateFormat      = "20060102T150405Z"
	BasicDateFormatShort = "20060102"
	TerminationString    = "sdk_request"
	Algorithm            = "SDK-HMAC-SHA256"
	PreSKString          = "SDK"
	HeaderXDate          = "x-sdk-date"
	HeaderDate           = "date"
	HeaderHost           = "host"
	HeaderAuthorization  = "Authorization"
)

BasicDateFormat and BasicDateFormatShort define aws-date format

Variables

This section is empty.

Functions

func AuthHeaderValue

func AuthHeaderValue(signature, accessKey, credentialScope, signedHeaders string) string

AuthHeaderValue Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign

func CanonicalHeaders

func CanonicalHeaders(r *http.Request) string

CanonicalHeaders adds appropriate Headers to the request

func CanonicalQueryString

func CanonicalQueryString(r *http.Request) string

CanonicalQueryString returns uri with query parameteres

func CanonicalRequest

func CanonicalRequest(r *http.Request) (string, error)

CanonicalRequest from a regular request string See http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html CanonicalRequest =

HTTPRequestMethod + '\n' +
CanonicalURI + '\n' +
CanonicalQueryString + '\n' +
CanonicalHeaders + '\n' +
SignedHeaders + '\n' +
HexEncode(Hash(RequestPayload))

func CanonicalURI

func CanonicalURI(r *http.Request) string

CanonicalURI returns request uri

func CredentialScope

func CredentialScope(t time.Time, regionName, serviceName string) string

CredentialScope See http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html

func GenerateSigningKey

func GenerateSigningKey(secretKey, regionName, serviceName string, t time.Time) ([]byte, error)

GenerateSigningKey Generate a "signing key" to sign the "String To Sign". See http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html

func HexEncodeSHA256Hash

func HexEncodeSHA256Hash(body []byte) (string, error)

HexEncodeSHA256Hash returns hexcode of sha256

func RequestPayload

func RequestPayload(r *http.Request) ([]byte, error)

RequestPayload adds body contents to the request

func SignStringToSign

func SignStringToSign(stringToSign string, signingKey []byte) (string, error)

SignStringToSign Create the HWS Signature. See http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html

func SignedHeaders

func SignedHeaders(r *http.Request) string

SignedHeaders adds signed headers to the request

func StringToSign

func StringToSign(canonicalRequest, credentialScope string, t time.Time) string

StringToSign Create a "String to Sign". See http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html

Types

type Signer

type Signer struct {
	AccessKey string
	SecretKey string
	Region    string
	Service   string
}

Signer Signature HWS meta

func (*Signer) Sign

func (s *Signer) Sign(r *http.Request) error

Sign set Authorization header

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL