timestamp

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 6 Imported by: 0

README

timestamp middleware

Validates request timestamps and optional nonces within a bounded replay store. New returns middleware plus a cleanup function.

handler, closeTimestamps := timestamp.New(timestamp.Config{
    Header: "X-Timestamp",
    NonceHeader: "X-Nonce",
    MaxSkew: 5 * time.Minute,
    MaxSize: 100_000,
    Required: true,
    RequireNonce: true,
    Store: kv.NewMemoryStore(),
})
defer closeTimestamps()
app.Use(handler)

A timestamp is not a signature. Bind method, target, identity, body digest, timestamp and nonce in authenticated request-signature middleware.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReplayStoreFull = errors.New("timestamp: replay store capacity exhausted")

Functions

func New

func New(cfg Config) (fh.HandlerFunc, func())

func Seen

func Seen(store kv.Store, key string, ttl time.Duration, maxSize int) (bool, error)

Types

type Config

type Config struct {
	Header         string
	NonceHeader    string
	MaxSkew        time.Duration
	MaxSize        int
	MaxNonceLength int
	Store          kv.Store
	KeyFunc        func(fh.Ctx) string
	Reject         func(fh.Ctx, string) error
	Skip           func(fh.Ctx) bool
	Required       bool
	RequireNonce   bool
}

Jump to

Keyboard shortcuts

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