sigv

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 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

Overview

Package sigv implements SynCloud access-key request signing (§7.1), shared by the controller (verify) and synctl/SDKs (sign). Modeled on AWS SigV4, simplified: the secret never travels on the wire, the body is covered by a hash, and requests older than MaxSkew are rejected.

Signed requests carry:

X-Syn-Date:           20261006T101500Z
X-Syn-Content-Sha256: <hex sha256 of body>
Authorization:        SYN1-HMAC-SHA256 Credential=<key id>, Signature=<hex>

Signature = hex(HMAC-SHA256(secret, StringToSign)), where StringToSign is the algorithm, date, method, escaped path, canonical query, host and body hash, each on its own line.

Index

Constants

View Source
const (
	Algorithm         = "SYN1-HMAC-SHA256"
	HeaderDate        = "X-Syn-Date"
	HeaderContentHash = "X-Syn-Content-Sha256"
	DateFormat        = "20060102T150405Z"
	// MaxSkew is how far a request's date may be from the server clock.
	MaxSkew = 5 * time.Minute
)

Variables

This section is empty.

Functions

func BodyHash

func BodyHash(body []byte) string

func CanonicalQuery

func CanonicalQuery(rawQuery string) string

CanonicalQuery sorts keys and values so client and server agree.

func IsSigned

func IsSigned(authz string) bool

IsSigned reports whether the Authorization header uses this scheme.

func ParseAuthorization

func ParseAuthorization(authz string) (keyID, sig string, err error)

ParseAuthorization extracts the key ID and signature.

func Sign

func Sign(req *http.Request, keyID, secret string, body []byte, now time.Time)

Sign adds the signing headers to req. body must be exactly the request body.

func StringToSign

func StringToSign(method, escapedPath, rawQuery, host, date, bodyHash string) string

func Verify

func Verify(req *http.Request, secret, sig string, body []byte, now time.Time) error

Verify checks a request's signature. body must be the full request body as received. It returns a client-safe error message on failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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