Documentation
¶
Overview ¶
Package httpsign provides utilities for signing and verifying HTTP requests.
Index ¶
- Constants
- Variables
- func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error)
- func Middleware(source VerifierSource, ...) func(http.Handler) http.Handler
- func Sign(s Signer, timestamp time.Time, r *http.Request) error
- func Verify(v Verifier, r *http.Request) error
- type Signer
- type SignerSource
- type Transport
- type Verifier
- type VerifierSource
Constants ¶
View Source
const ( SignatureHeader = "X-Signature" TimestampHeader = "X-Signature-Timestamp" KidHeader = "X-Key-ID" )
Variables ¶
View Source
var ( // ErrRequestVerification represents a failure to verify an HTTP request. ErrRequestVerification = errors.New("failed to verify HTTP request") )
Functions ¶
func DefaultErrorHandler ¶
func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error)
DefaultErrorHandler handles errors as follows:
- If the error is ErrRequestVerification, it sends a 401 Unauthorized response.
- For any other errors, it defaults to sending a 500 Internal Server Error response.
func Middleware ¶
func Middleware( source VerifierSource, errHandler func(w http.ResponseWriter, r *http.Request, err error), ) func(http.Handler) http.Handler
Middleware creates middleware that verifies HTTP request signatures using a Verifier from the provided source and handles errors with a custom handler.
Types ¶
type SignerSource ¶ added in v0.2.0
SignerSource provides a Signer given a key ID. It must be safe for concurrent use by multiple goroutines.
type Transport ¶
type Transport struct {
// Base is the base http.RoundTripper used to make HTTP requests.
// By default, http.DefaultTransport is used.
Base http.RoundTripper
// contains filtered or unexported fields
}
Transport is an http.RoundTripper which signs outgoing HTTP requests.
func NewTransport ¶
func NewTransport(source SignerSource, kid string) *Transport
NewTransport returns a new Transport using a SignerSource with the provided key ID.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ecdsa provides utilities for signing and verifying messages using ECDSA.
|
Package ecdsa provides utilities for signing and verifying messages using ECDSA. |
|
Package ed25519 provides utilities for signing and verifying messages using Ed25519.
|
Package ed25519 provides utilities for signing and verifying messages using Ed25519. |
|
Package hmac provides utilities for signing and verifying messages using HMAC.
|
Package hmac provides utilities for signing and verifying messages using HMAC. |
|
Package rsa provides utilities for signing and verifying messages using RSA.
|
Package rsa provides utilities for signing and verifying messages using RSA. |
Click to show internal directories.
Click to hide internal directories.