httpsig

package
v0.0.0-...-7b7c10a Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("invalid HTTP signature")

ErrInvalidSignature indicates that the signature is not valid for the given data.

Functions

This section is empty.

Types

type SecretRetriever

type SecretRetriever struct{}

SecretRetriever implements a custom key retriever to be used with the HTTP signature library.

func (*SecretRetriever) Get

func (r *SecretRetriever) Get(keyID string) (httpsig.Secret, error)

Get returns a 'secret' that directs the HTTP signature library to use the custom SignatureHashAlgorithm above.

type SignatureHashAlgorithm

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

SignatureHashAlgorithm is a custom httpsignatures.SignatureHashAlgorithm that uses ed25519 key to sign HTTP requests.

func NewSignerAlgorithm

func NewSignerAlgorithm(privateKey ed25519.PrivateKey) *SignatureHashAlgorithm

NewSignerAlgorithm returns a new SignatureHashAlgorithm which uses ed25519 key to sign HTTP requests.

func NewVerifierAlgorithm

func NewVerifierAlgorithm(pubKeyResolver keyResolver) *SignatureHashAlgorithm

NewVerifierAlgorithm returns a new SignatureHashAlgorithm which is used to verify the signature in the HTTP request header.

func (*SignatureHashAlgorithm) Algorithm

func (a *SignatureHashAlgorithm) Algorithm() string

Algorithm returns this algorithm's name.

func (*SignatureHashAlgorithm) Create

func (a *SignatureHashAlgorithm) Create(_ httpsig.Secret, data []byte) ([]byte, error)

Create signs data with the secret.

func (*SignatureHashAlgorithm) Verify

func (a *SignatureHashAlgorithm) Verify(secret httpsig.Secret, data, signature []byte) error

Verify verifies the signature over data with the secret.

type Signer

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

Signer signs HTTP requests.

func NewSigner

func NewSigner(cfg SignerConfig, privateKey ed25519.PrivateKey) *Signer

NewSigner returns a new signer.

func (*Signer) SignRequest

func (s *Signer) SignRequest(pubKeyID string, req *http.Request) error

SignRequest signs an HTTP request.

type SignerConfig

type SignerConfig struct {
	Headers []string
}

SignerConfig contains the configuration for signing HTTP requests.

func DefaultGetSignerConfig

func DefaultGetSignerConfig() SignerConfig

DefaultGetSignerConfig returns the default configuration for signing HTTP GET requests.

func DefaultPostSignerConfig

func DefaultPostSignerConfig() SignerConfig

DefaultPostSignerConfig returns the default configuration for signing HTTP POST requests.

type Verifier

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

Verifier verifies signatures of HTTP requests.

func NewVerifier

func NewVerifier(pubKeyResolver keyResolver) *Verifier

NewVerifier returns a new HTTP signature verifier.

func (*Verifier) VerifyRequest

func (v *Verifier) VerifyRequest(req *http.Request) (bool, string)

VerifyRequest verifies the following: - HTTP signature on the request.

Returns: - true if the signature was successfully verified, otherwise false. - Subject DID if the signature was successfully verified.

Jump to

Keyboard shortcuts

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