auth

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: Apache-2.0 Imports: 9 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"
	HeaderContentSha256  = "x-sdk-content-sha256"
	// todo: use the region and service.
	DefaultRegion  = "default"
	DefaultService = "apigateway"
)

BasicDateFormat and BasicDateFormatShort define aws-date format

Variables

This section is empty.

Functions

func AuthHeaderValue

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

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

func CanonicalQueryString

func CanonicalQueryString(r *http.Request) string

CanonicalQueryString

func CanonicalRequest

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

Build a 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

Return the Credential Scope. 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)

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

func SignStringToSign

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

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

func StringToSign

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

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 interface {
	Sign(*http.Request) error
}

type SignerHws

type SignerHws struct {
	AppKey    string
	AppSecret string
	Region    string
	Service   string
}

Signature HWS meta

func (*SignerHws) Sign

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

SignRequest set Authorization header

Jump to

Keyboard shortcuts

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