httpsigning

package
v0.0.0-...-7d3c31f Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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