signer

package
v0.0.0-...-ab87613 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSigLabel    = errors.New("missing sigLabel")
	ErrNothingToSign = errors.New("there are nothing to sign in the http message")
)

Functions

This section is empty.

Types

type EcdsaP256Sha256SigningAlgorithm

type EcdsaP256Sha256SigningAlgorithm struct {
	verifier.EcdsaP256Sha256VerifyingAlgorithm
	// contains filtered or unexported fields
}

func NewEcdsaSha256

func NewEcdsaSha256(key *ecdsa.PrivateKey) (e EcdsaP256Sha256SigningAlgorithm, err error)

func (EcdsaP256Sha256SigningAlgorithm) Sign

func (alg EcdsaP256Sha256SigningAlgorithm) Sign(b []byte) ([]byte, error)

type EcdsaP384Sha384SigningAlgorithm

type EcdsaP384Sha384SigningAlgorithm struct {
	verifier.EcdsaP384Sha384VerifyingAlgorithm
	// contains filtered or unexported fields
}

func NewEcdsaP384Sha384SigningAlgorithm

func NewEcdsaP384Sha384SigningAlgorithm(key *ecdsa.PrivateKey) (e EcdsaP384Sha384SigningAlgorithm, err error)

func (EcdsaP384Sha384SigningAlgorithm) Sign

func (alg EcdsaP384Sha384SigningAlgorithm) Sign(b []byte) ([]byte, error)

type HttpMessageSigner

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

HttpMessageSigner implements Signer using SigningAlgorithm

func New

func New(alg SigningAlgorithm, sigLabel string, opts ...Option) (*HttpMessageSigner, error)

func (*HttpMessageSigner) SignRequest

func (s *HttpMessageSigner) SignRequest(req *http.Request) error

type Option

type Option func(*HttpMessageSigner)

func SignBody

func SignBody() Option

SignBody adds "Content-Length" and "Content-Digest" headers as components if there is a body

func WithAlg

func WithAlg() Option

WithAlg adds the "Alg" signature parameter and automatically gets the value based on the signing algorithm and hash used

func WithAuthority

func WithAuthority() Option

func WithCreated

func WithCreated() Option

WithCreated adds the "Created" signature parameter

func WithCustomAlg

func WithCustomAlg(alg string) Option

WithCustomAlg adds the "Alg" signature parameter with a custom value

func WithExpires

func WithExpires() Option

WithExpires adds the "Expires" signature parameter

func WithHeaders

func WithHeaders(headers ...string) Option

WithHeaders adds headers (canonicalized) to the components

func WithKeyId

func WithKeyId(keyId string) Option

WithKeyId adds a specific key ID to the signature parameters

func WithMethod

func WithMethod() Option

func WithNonce

func WithNonce() Option

WithNonce adds the "Nonce" signature parameter

func WithPath

func WithPath() Option

func WithQuery

func WithQuery() Option

func WithQueryParam

func WithQueryParam() Option

func WithRequestTarget

func WithRequestTarget() Option

func WithScheme

func WithScheme() Option

func WithStatus

func WithStatus() Option

func WithTargetUri

func WithTargetUri() Option

type Signer

type Signer interface {
	SignRequest(req *http.Request) error
}

type SigningAlgorithm

type SigningAlgorithm interface {
	httpsig.Algorithm
	Sign(b []byte) ([]byte, error)
}

type SigningError

type SigningError struct {
}

func (SigningError) Error

func (e SigningError) Error() string

Jump to

Keyboard shortcuts

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