sign

package
v0.0.0-...-9fdd194 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePath

func EncodePath(pathName string) string

EncodePath encode the strings from UTF-8 byte representations to HTML hex escape sequences

This is necessary since regular url.Parse() and url.Encode() functions do not support UTF-8 non english characters cannot be parsed due to the nature in which url.Encode() is written

This function on the other hand is a direct replacement for url.Encode() technique to support pretty much every UTF-8 character.

func GetCanonicalRequest

func GetCanonicalRequest(extractedSignedHeaders http.Header, payload, queryStr, urlPath, method string) string

GetCanonicalRequest generate a canonical request of style

canonicalRequest =

<HTTPMethod>\n
<CanonicalURI>\n
<CanonicalQueryString>\n
<CanonicalHeaders>\n
<SignedHeaders>\n
<HashedPayload>

func GetContentSHA256Checksum

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

func GetSignature

func GetSignature(signingKey []byte, stringToSign string) string

GetSignature final signature in hexadecimal form.

func GetSignedHeaders

func GetSignedHeaders(signedHeaders http.Header) string

GetSignedHeaders generate a string i.e alphabetically sorted, semicolon-separated list of lowercase request header names

func GetSigningKey

func GetSigningKey(secretKey string, t time.Time, region string) []byte

GetSigningKey hmac seed to calculate final signature.

func GetStringToSign

func GetStringToSign(canonicalRequest string, t time.Time, scope string) string

GetStringToSign a string based on selected query values.

func IsRequestSignatureV4

func IsRequestSignatureV4(r *http.Request) bool

IsRequestSignatureV4 Verify if request has AWS Signature Version '4'.

Types

type AuthType

type AuthType int

AuthType Authorization type.

const (
	AuthTypeUnknown AuthType = iota
	AuthTypeAnonymous
	AuthTypePresigned
	AuthTypePresignedV2
	AuthTypePostPolicy
	AuthTypeStreamingSigned
	AuthTypeSigned
	AuthTypeSignedV2
	AuthTypeJWT
	AuthTypeSTS
)

List of all supported auth types.

func GetRequestAuthType

func GetRequestAuthType(r *http.Request) AuthType

GetRequestAuthType Get request authentication type.

type Option

type Option func(svc *service)

type Service

type Service interface {
	SetSecretGetter(f func(key string) (secret string, exists, enable bool, err error))
	VerifyRequestSignature(r *http.Request) (ack string, rerr *responses.Error)
}

func NewService

func NewService(options ...Option) Service

Jump to

Keyboard shortcuts

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