HTTP Signatures
This crate is used to create and verify HTTP Signatures, defined here. It has support for Hyper, Rocket, and Reqwest types, although currently these adapters have not been tested. In the future, I might also support Iron middleware for verification.
Usage
With Hyper
Add this to your Cargo.toml
[]
= "0.1"
= ["use_hyper"]
Client
Use it when building a request as follows.
extern crate hyper;
extern crate tokio_core;
extern crate http_signatures;
use Core;
use ;
use ;
let key_id = "some-username-or-something";
let private_key = File.open?;
let mut core = new?;
let client = new;
let mut req = new;
req.headers_mut.set;
req.headers_mut.set;
// Add the HTTP Signature
req.with_http_signature?;
req.set_body;
let post = client.request.and_then;
core.run;
Server
This is a very basic example server outline that should give you a general idea of how to set up a Hyper server that verifies HTTP Signatures. This is not meant to be code that actually works.
extern crate hyper;
extern crate futures;
extern crate http_signatures;
use Future;
use ContentLength;
use ;
use ;
;
With Reqwest
Add this to your Cargo.toml
[]
= "0.1"
= ["use_reqwest"]
In your code, use it when building a request as follows.
extern crate reqwest;
extern crate http_signatures;
use Client;
use ;
let key_id = "some-username-or-something".into;
let private_key = File.open?;
let client = new;
let req = client.post
.body
.with_http_signature?;
execute?;
With Rocket
Add this to your Cargo.toml
[]
= "0.1"
= ["use_rocket"]
In your code, use it in a route like so
use ;
.>
License
HTTP Signatures is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
HTTP Signatures is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of HTTP Signatures
You should have received a copy of the GNU General Public License along with HTTP Signatures If not, see http://www.gnu.org/licenses/.