hmac

package
v0.0.0-...-b96c0aa Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotValidError   = Error("signature not valid")
	ExpiredError    = Error("signature expired")
	BadRequestError = Error("bad request")
)

Error constants retured by various functions.

Variables

View Source
var DebugOut = log.New(io.Discard, "[DEBUG] ", 0)

DebugOut is an optional logger to receive debugging messages

Functions

func NewVerifier

func NewVerifier(srv imageserver.Server, key, salt string, expiration time.Duration) imageserver.Server

NewVerifier returns an initialized Verifier. If expiration is 0, expirations are not enforced.

Types

type Error

type Error string

Error is an error type

func (Error) Error

func (e Error) Error() string

Error returns the stringified version of Error

type Parser

type Parser struct{}

Parser is a imageserver/http.Parser implementation for imageserver/image/expiration.Processor.

func (*Parser) Parse

func (prs *Parser) Parse(req *http.Request, params imageserver.Params) error

Parse implements imageserver/http.Parser.

func (*Parser) Resolve

func (prs *Parser) Resolve(p string) (httpParam string)

Resolve implements imageserver/http.Parser.

type Signer

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

Signer is an http.Handler that signs the request URL + query parameters and redirects to the signed URL.

func NewSigner

func NewSigner(key, salt string, expires time.Duration) *Signer

NewSigner returns an initialized HMACSigner. If expires is 0, then expiration is not computed.

func (*Signer) ServeHTTP

func (s *Signer) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP handles the request

type Verifier

type Verifier struct {
	Next imageserver.Server
	// contains filtered or unexported fields
}

Verifier is an imageserver.Server that verifies the signature and possibly the timestamp of a request URL

func (*Verifier) Get

func (srv *Verifier) Get(params imageserver.Params) (*imageserver.Image, error)

Get does the HMAC verification, and possibly expiration calculation, of the request

Jump to

Keyboard shortcuts

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