httpsigning

package
v0.0.0-...-04ccfb0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SigningAlgorithm is "HMAC-SHA256".
	SigningAlgorithm = "HMAC-SHA256"
)
View Source
const (
	// TimeFormat is YYYYMMDD'T'HHMMSS'Z'
	TimeFormat = "2006-01-02T15:04:05Z"
)

Variables

View Source
var ErrExpiredSignature = apierrors.Invalid.WithReason("ExpiredSignature").New("expired signature")
View Source
var InvalidSignature = apierrors.Invalid.WithReason("InvalidSignature")
View Source
var InvalidSignatureQueryParam = apierrors.Invalid.WithReason("InvalidSignatureQueryParam")

Functions

func CanonicalHeaders

func CanonicalHeaders(host httputil.HTTPHost) (canonicalHeaders string)

CanonicalHeaders computes CANONICAL_HEADERS and SIGNED_HEADERS. Currently only Host is signed.

func CanonicalQueryString

func CanonicalQueryString(u *url.URL) string

CanonicalQueryString turns the query string of u into string.

func CanonicalRequest

func CanonicalRequest(host httputil.HTTPHost, r *http.Request) []byte

CanonicalRequest turns r into bytes.

func FormatTime

func FormatTime(t time.Time) string

FormatTime formats t as TimeFormat.

func HMACSHA256

func HMACSHA256(key []byte, data []byte) []byte

HMACSHA256 is HMAC-SHA256.

func HashedCanonicalRequest

func HashedCanonicalRequest(host httputil.HTTPHost, r *http.Request) (hashed string, canonicalRequest []byte)

HashedCanonicalRequest is HEX(SHA256(CanonicalRequest(host, r))).

func Hex

func Hex(b []byte) string

Hex is hex.EncodeToString.

func SHA256

func SHA256(b []byte) []byte

SHA256 is sha256.Sum256.

func Sign

func Sign(key []byte, r *http.Request, t time.Time, expires int)

Sign turns r into a signed http.Request.

func StringToSign

func StringToSign(host httputil.HTTPHost, r *http.Request, t time.Time) (stringToSign []byte, canonicalRequest []byte)

StringToSign computes StringToSign.

func Verify

func Verify(key []byte, host httputil.HTTPHost, r *http.Request, now time.Time) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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