Crate http_sig[][src]

Expand description

Implementation of the IETF draft ‘Signing HTTP Messages’ https://tools.ietf.org/id/draft-cavage-http-signatures-12.html

Features

This crate is intended to be used with multiple different HTTP clients and/or servers. As such, client/server-specific implementations are gated by correspondingly named features.

Supported crates:

Crate / Feature nameClient/ServerNotes
reqwestClientSupports blocking and non-blocking requests.1
rouilleServer
  1. Due to limitations of the reqwest API, digests can only be calculated automatically for non-blocking non-streaming requests. For blocking or streaming requests, the user must add the digest manually before signing the request, or else the Digest header will not be included in the signature.

Supported signature algorithms:

Algorithm registry: https://tools.ietf.org/id/draft-cavage-http-signatures-12.html#hsa-registry

  • hmac-sha256

Supported digest algorithms:

Digest registry: https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml

  • SHA-256
  • SHA-512

Example usage (reqwest)

use http_sig::*;

const SECRET_KEY: &[u8] = b"secret";

let config = SigningConfig::new_default("My Key", SECRET_KEY);

let client = reqwest::blocking::Client::new();

let req = client
    .get("http://localhost:8080/")
    .build()
    .unwrap()
    .signed(&config)
    .unwrap();

let result = client.execute(req).unwrap();

Modules

Module containg a mock request type which implements both ClientRequestLike and ServerRequestLike for testing.

Structs

Configuration for computing the canonical “signature string” of a request.

Supports the SHA-256 and SHA-512 digest algorithms.

Implementation of the ’ hmac-sha256 ’ HTTP signature scheme.

Implementation of the ’ hmac-sha512 ’ HTTP signature scheme.

In order to verify the signature on a rouille request, the request body must be consumed by the verification process. This type is used to return the request body contents on completion of a successful signature verification.

Implementation of the signing half of the ’ rsa-sha256 ’ HTTP signature scheme.

Implementation of the verification half of the ’ rsa-sha256 ’ HTTP signature scheme.

Implementation of the signing half of the ’ rsa-sha512 ’ HTTP signature scheme.

Implementation of the verification half of the ’ rsa-sha512 ’ HTTP signature scheme.

Opaque struct storing a computed signature string.

The configuration used for signing HTTP requests.

Implementation of a simple key store.

Contains information about a successfully validated request.

The configuration used for verifying HTTP requests.

This error indicates that we failed to verify the request. As a result the request should be ignored.

Enums

The types of error which may occur whilst computing the canonical “signature string” for a request.

A header which can be incorporated into a HTTP signature.

Pseudo-headers are used to incorporate additional information into a HTTP signature for which there is no corresponding HTTP header.

The types of error which may occur whilst signing.

Traits

Extension method for computing the canonical “signature string” of a request.

This trait is to be implemented for types representing an outgoing HTTP request. The HTTP signing extension methods are available on any type implementing this trait.

The verification process will use this trait to find the appropriate digest algorithm to use when verifying the body of a request.

Implementations of this trait correspond to digest algorithms listed here: https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml

Implements the signing half of an HTTP signature algorithm. For symmetric algorithms the same type implements both signing and verification.

Implements the verification half of an HTTP signature algorithm. For symmetric algorithms the same type implements both signing and verification.

The verification process will use this trait to find the appropriate key and algorithm to use for verifying a request.

Base trait for all request types

This trait is to be implemented for types representing an incoming HTTP request. The HTTP verification extension methods are available on any type implementing this trait.

Import this trait to get access to access the signed and sign methods on all types implementing ClientRequestLike.

Import this trait to get access to access the verify method on all types implementing ServerRequestLike.