sigset

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package signature set provides a data structure describing a set of HTTP message signatures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultipleSignaturesError

type MultipleSignaturesError struct {
	Tag    string
	First  string
	Second string
}

func (MultipleSignaturesError) Error

func (e MultipleSignaturesError) Error() string

type Set

type Set struct {
	Messages map[string]*signature.Message
}

Set of signatures in an HTTP request.

The index of the map is the label given to the signatures. When parsing signatures do not rely upon the label, use the tag in the signature params instead.

func Unmarshal

func Unmarshal(r *http.Request) (*Set, error)

Unmarshal a set of signatures from an HTTP request, by reading the Signature-Input and Signature headers.

The Signature-Input field identifies the covered components and parameters that describe how the signature was generated, while the Signature field contains the signature value. Each field MAY contain multiple labeled values.

An HTTP message signature is identified by a label within an HTTP message. This label MUST be unique within a given HTTP message and MUST be used in both the Signature-Input field and the Signature field. The label is chosen by the signer, except where a specific label is dictated by protocol negotiations such as those described in Section 5.

An HTTP message signature MUST use both the Signature-Input field and the Signature field, and each field MUST contain the same labels. The presence of a label in one field but not the other is an error.

func (*Set) Add

func (s *Set) Add(m *signature.Message)

Add a signature message to the set.

Add() gives a label such as 'sig1' 'sig2', 'sig3' etc to the message.

To customise the label, add the message to the Messages field directly.

func (*Set) Find

func (s *Set) Find(tag string) (*signature.Message, error)

Find a signature matching the tag.

If the signature cannot be found, or there are multiple signatures matching the tag, an error is returned.

Returns an error if the supplied tag is empty.

func (*Set) Include

func (s *Set) Include(r *http.Request) error

Include a signature set in an HTTP request by setting the Signature-Input and Signature headers.

If Signature-Input or Signature headers exist they will be overwritten.

Jump to

Keyboard shortcuts

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