mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-25 02:41:00 +00:00
actix-web 4 stable
This commit is contained in:
parent
8c8fef35fc
commit
e02a40e3a5
5 changed files with 28 additions and 27 deletions
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "http-signature-normalization-actix"
|
||||
description = "An HTTP Signatures library that leaves the signing to you"
|
||||
version = "0.6.0-beta.5"
|
||||
version = "0.6.0-beta.6"
|
||||
authors = ["asonix <asonix@asonix.dog>"]
|
||||
license-file = "LICENSE"
|
||||
readme = "README.md"
|
||||
|
@ -27,10 +27,10 @@ name = "client"
|
|||
required-features = ["client", "sha-2"]
|
||||
|
||||
[dependencies]
|
||||
actix-http = { version = "=3.0.0-rc.2", default-features = false }
|
||||
actix-http = { version = "3.0.0", default-features = false }
|
||||
actix-rt = "2.6.0"
|
||||
actix-web = { version = "=4.0.0-rc.3", default-features = false, optional = true }
|
||||
awc = { version = "3.0.0-beta.20", default-features = false, optional = true }
|
||||
actix-web = { version = "4.0.0", default-features = false, optional = true }
|
||||
awc = { version = "3.0.0-beta.21", default-features = false, optional = true }
|
||||
base64 = { version = "0.13", optional = true }
|
||||
futures-util = { version = "0.3", default-features = false }
|
||||
http-signature-normalization = { version = "0.6.0", path = ".." }
|
||||
|
@ -44,7 +44,7 @@ tracing-futures = "0.2"
|
|||
|
||||
[dev-dependencies]
|
||||
actix-rt = "2.6.0"
|
||||
tracing-actix-web = { version = "0.5.0-rc.3" }
|
||||
tracing-actix-web = { version = "0.5.0" }
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
|
|
@ -27,7 +27,8 @@ pub trait DigestName {
|
|||
#[cfg(feature = "client")]
|
||||
mod client {
|
||||
use crate::{Config, PrepareSignError, Sign};
|
||||
use actix_http::{error::BlockingError, header::InvalidHeaderValue};
|
||||
use actix_http::header::InvalidHeaderValue;
|
||||
use actix_rt::task::JoinError;
|
||||
use awc::{ClientRequest, SendClientRequest};
|
||||
use std::{fmt::Display, future::Future, pin::Pin};
|
||||
|
||||
|
@ -56,7 +57,7 @@ mod client {
|
|||
) -> Pin<Box<dyn Future<Output = Result<DigestClient<V>, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
@ -78,7 +79,7 @@ mod client {
|
|||
) -> Pin<Box<dyn Future<Output = Result<DigestClient<V>, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use actix_http::{error::BlockingError, header::InvalidHeaderValue};
|
||||
use actix_http::{header::InvalidHeaderValue};
|
||||
use actix_rt::task::JoinError;
|
||||
use awc::ClientRequest;
|
||||
use std::{fmt::Display, future::Future, pin::Pin};
|
||||
|
||||
|
@ -18,7 +19,7 @@ impl SignExt for ClientRequest {
|
|||
) -> Pin<Box<dyn Future<Output = Result<DigestClient<V>, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
@ -34,7 +35,7 @@ impl SignExt for ClientRequest {
|
|||
let d = digest.compute(v.as_ref());
|
||||
Ok((d, v)) as Result<(String, V), E>
|
||||
})
|
||||
.await.map_err(|_| BlockingError)??;
|
||||
.await??;
|
||||
|
||||
let c = self
|
||||
.insert_header(("Digest", format!("{}={}", D::NAME, d)))
|
||||
|
@ -55,7 +56,7 @@ impl SignExt for ClientRequest {
|
|||
) -> Pin<Box<dyn Future<Output = Result<DigestClient<V>, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
@ -71,7 +72,7 @@ impl SignExt for ClientRequest {
|
|||
let d = digest.compute(v.as_ref());
|
||||
Ok((d, v)) as Result<(String, V), E>
|
||||
})
|
||||
.await.map_err(|_| BlockingError)??;
|
||||
.await??;
|
||||
|
||||
let c = self
|
||||
.insert_header(("Digest", format!("{}={}", D::NAME, d)))
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
//!
|
||||
//! ### Use it in a client
|
||||
//! ```rust,ignore
|
||||
//! use actix_web::error::BlockingError;
|
||||
//! use actix_rt::task::JoinError;
|
||||
//! use awc::Client;
|
||||
//! use http_signature_normalization_actix::prelude::*;
|
||||
//! use sha2::{Digest, Sha256};
|
||||
|
@ -152,8 +152,8 @@
|
|||
//! Canceled,
|
||||
//! }
|
||||
//!
|
||||
//! impl From<BlockingError> for MyError {
|
||||
//! fn from(_: BlockingError) -> Self {
|
||||
//! impl From<JoinError> for MyError {
|
||||
//! fn from(_: JoinError) -> Self {
|
||||
//! MyError::Canceled,
|
||||
//! }
|
||||
//! }
|
||||
|
@ -240,10 +240,8 @@ pub struct Config {
|
|||
#[cfg(feature = "client")]
|
||||
mod client {
|
||||
use super::{Config, RequiredError};
|
||||
use actix_http::{
|
||||
error::BlockingError,
|
||||
header::{InvalidHeaderValue, ToStrError},
|
||||
};
|
||||
use actix_http::header::{InvalidHeaderValue, ToStrError};
|
||||
use actix_rt::task::JoinError;
|
||||
use std::{fmt::Display, future::Future, pin::Pin};
|
||||
|
||||
/// A trait implemented by the awc ClientRequest type to add an HTTP signature to the request
|
||||
|
@ -257,7 +255,7 @@ mod client {
|
|||
) -> Pin<Box<dyn Future<Output = Result<Self, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
@ -275,7 +273,7 @@ mod client {
|
|||
) -> Pin<Box<dyn Future<Output = Result<Self, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use actix_http::{error::BlockingError, header::InvalidHeaderValue};
|
||||
use actix_http::{header::InvalidHeaderValue};
|
||||
use awc::ClientRequest;
|
||||
use actix_rt::task::JoinError;
|
||||
use std::{fmt::Display, future::Future, pin::Pin};
|
||||
|
||||
use crate::{create::Signed, Config, PrepareSignError, Sign};
|
||||
|
@ -13,7 +14,7 @@ impl Sign for ClientRequest {
|
|||
) -> Pin<Box<dyn Future<Output = Result<Self, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
@ -37,7 +38,7 @@ impl Sign for ClientRequest {
|
|||
) -> Pin<Box<dyn Future<Output = Result<Self, E>>>>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError>
|
||||
E: From<JoinError>
|
||||
+ From<PrepareSignError>
|
||||
+ From<InvalidHeaderValue>
|
||||
+ std::fmt::Debug
|
||||
|
@ -62,7 +63,7 @@ async fn prepare<F, E, K>(
|
|||
) -> Result<Signed, E>
|
||||
where
|
||||
F: FnOnce(&str) -> Result<String, E> + Send + 'static,
|
||||
E: From<BlockingError> + From<PrepareSignError> + std::fmt::Debug + Send + 'static,
|
||||
E: From<JoinError> + From<PrepareSignError> + std::fmt::Debug + Send + 'static,
|
||||
K: Display,
|
||||
{
|
||||
let mut headers = request.headers().clone();
|
||||
|
@ -92,7 +93,7 @@ where
|
|||
|
||||
let key_id = key_id.to_string();
|
||||
|
||||
let signed = actix_rt::task::spawn_blocking(move || unsigned.sign(key_id, f)).await.map_err(|_| BlockingError)??;
|
||||
let signed = actix_rt::task::spawn_blocking(move || unsigned.sign(key_id, f)).await??;
|
||||
|
||||
Ok(signed)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue