urlsigner

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCorruptSignature = errors.New("corrupt signature")
View Source
var ErrExpiredSignature = errors.New("expired signature")
View Source
var ErrHeaderMismatch = errors.New("header mismatch")
View Source
var ErrInvalidSignature = errors.New("invalid signature")
View Source
var HdrSignature = "X-Psn"
View Source
var QuerySignature = "psn"

Functions

This section is empty.

Types

type Digest

type Digest struct {
	Expires       *time.Time
	Headers       map[string]string
	SecretHeaders map[string]string
	Rewrite       string
}

The signed digest included in the signature.

func (*Digest) MarshalBinary

func (d *Digest) MarshalBinary() (data []byte, err error)

func (*Digest) UnmarshalBinary

func (d *Digest) UnmarshalBinary(data []byte) (err error)

type Options

type Options struct {
	// The URL to sign.
	URL string `json:"url"`
	// The expiration time of the signed URL.
	Expires *time.Time `json:"expires,omitempty"`
	// Headers to include in the signed URL.
	Headers map[string]string `json:"headers,omitempty"`
	// Headers to include in the request after the signature is verified.
	SecretHeaders map[string]string `json:"secrets,omitempty"`
	// Secret internal location for the URL.
	Rewrite string `json:"rewrite,omitempty"`
}

Defines the full set of options for signing a URL.

func (*Options) ToDigest

func (o *Options) ToDigest() (d Digest)

type Signer

type Signer struct {
	Key []byte // 16-byte key for AES-128-GCM
}

func New

func New(secret string) *Signer

func (*Signer) Authenticate

func (s *Signer) Authenticate(r *http.Request) (signed bool, err error)

func (*Signer) GCM

func (s *Signer) GCM() (gcm cipher.AEAD, err error)

func (*Signer) RawAuthenticate

func (s *Signer) RawAuthenticate(signature string, ad []byte) ([]byte, error)

func (*Signer) RawSign

func (s *Signer) RawSign(blob []byte, ad []byte) (string, error)

func (*Signer) Sign

func (s *Signer) Sign(o Options) (string, error)

Jump to

Keyboard shortcuts

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