hmac

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 9 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

This section is empty.

Functions

func NewVerifier

func NewVerifier(srv imageserver.Server, key 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 []byte, 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