studiosign

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 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 studiosign is the request-signing scheme shared by the studio proxy client (internal/studio) and the API's /admin/studio middleware.

X-Signature = "sha256=" + hex(HMAC-SHA256(secret,
    "<unix-ts>.<nonce>.<METHOD>.<request-uri>.<body>"))

The timestamp bounds how long a captured request stays valid, the nonce makes every request single-use, and binding the method and URI stops a signature from being replayed against another endpoint.

Index

Constants

View Source
const (
	HeaderSignature = "X-Signature"
	HeaderTimestamp = "X-Timestamp"
	HeaderNonce     = "X-Nonce"

	// MaxSkew is the accepted clock difference between client and server.
	MaxSkew = 5 * time.Minute
)

Variables

This section is empty.

Functions

func NewNonce

func NewNonce() string

NewNonce returns a random single-use request id.

func Sign

func Sign(secret string, ts int64, nonce, method, requestURI string, body []byte) string

Sign returns the X-Signature value for a request.

func ValidNonce

func ValidNonce(n string) bool

ValidNonce reports whether n has the shape NewNonce produces.

Types

type NonceCache

type NonceCache struct {
	// contains filtered or unexported fields
}

NonceCache remembers nonces for twice MaxSkew (a timestamp is accepted up to MaxSkew in either direction), so each signed request is accepted once.

func NewNonceCache

func NewNonceCache() *NonceCache

func (*NonceCache) Use

func (c *NonceCache) Use(nonce string, now time.Time) bool

Use records nonce and reports whether it was unused.

Jump to

Keyboard shortcuts

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