signature

package
v0.0.0-...-1458d31 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParseV2Error = errs.Class("parse v2")

ParseV2Error is the default error class for V2 parsing errors.

View Source
var ParseV2FromHeaderError = errs.Class("header")

ParseV2FromHeaderError is the default error class for V2 parsing header errors.

View Source
var ParseV2FromQueryError = errs.Class("query")

ParseV2FromQueryError is the default error class for V2 parsing query errors.

View Source
var ParseV4CredentialError = errs.Class("credential")

ParseV4CredentialError is the default error class for V4 parsing credential errors.

View Source
var ParseV4Error = errs.Class("parse v4")

ParseV4Error is the default error class for V4 parsing errors.

View Source
var ParseV4FromHeaderError = errs.Class("header")

ParseV4FromHeaderError is the default error class for V4 parsing header errors.

View Source
var ParseV4FromQueryError = errs.Class("query")

ParseV4FromQueryError is the default error class for V4 parsing query errors.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	Ok(r *http.Request, secretKey string) (err error)
}

Checker implements the Ok interface for validating signatures against a given request and secret.

func GetAccessKeyIDWithChecker

func GetAccessKeyIDWithChecker(r *http.Request) (string, Checker, error)

GetAccessKeyIDWithChecker returns the access key ID from the request and a signature checker.

type Credentials

type Credentials struct {
	AccessKeyID string
	SecretKey   string
}

Credentials are the key and secret associated with this request.

func GetCredentials

func GetCredentials(ctx context.Context) *Credentials

GetCredentials returns the credentials.

type SecretKeyGetter

type SecretKeyGetter interface {
	Get(ctx context.Context, accessKeyID string) (secretKey string, err error)
}

SecretKeyGetter returns a secret key from an access key.

type Signature

type Signature struct {
	SecretKey SecretKeyGetter
}

Signature middleware

func (*Signature) Middleware

func (s *Signature) Middleware(next http.Handler) http.Handler

Middleware implements mux.Middlware.

type V2

type V2 struct {
	AccessKeyID string
	Signature   string
	Expires     time.Time

	FromHeader bool
}

V2 data

func ParseV2

func ParseV2(r *http.Request) (*V2, error)

ParseV2 parses a V2 signature from the request.

func ParseV2FromHeader

func ParseV2FromHeader(r *http.Request) (_ *V2, err error)

ParseV2FromHeader parses a V2 signature from the request headers.

func ParseV2FromQuery

func ParseV2FromQuery(r *http.Request) (_ *V2, err error)

ParseV2FromQuery parses a V2 signature from the query parameters.

func (*V2) Ok

func (v2 *V2) Ok(r *http.Request, secretKey string) (err error)

Ok validates the v2 signature against a given request.

type V4

type V4 struct {
	Credential    *V4Credential
	SignedHeaders []string
	Signature     string

	ContentSHA256 string
	Date          time.Time

	FromHeader bool
}

V4 data

func ParseV4

func ParseV4(r *http.Request) (*V4, error)

ParseV4 parses a V4 signature from the request.

func ParseV4FromHeader

func ParseV4FromHeader(r *http.Request) (_ *V4, err error)

ParseV4FromHeader parses a V4 signature from the request headers.

func ParseV4FromQuery

func ParseV4FromQuery(r *http.Request) (_ *V4, err error)

ParseV4FromQuery parses a V4 signature from the query parameters.

func (*V4) Ok

func (v4 *V4) Ok(r *http.Request, secretKey string) (err error)

Ok validates the v4 signature against a given request.

type V4Credential

type V4Credential struct {
	AccessKeyID string
	Date        time.Time
	Region      string
	Service     string
}

V4Credential data

func ParseV4Credential

func ParseV4Credential(data string) (*V4Credential, error)

ParseV4Credential parses the credential into it's parts.

Jump to

Keyboard shortcuts

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