Remove verify trait to encourage middleware use

This commit is contained in:
asonix 2019-09-13 18:33:54 -05:00
parent f4139af189
commit 6f0ff4ca5f
2 changed files with 7 additions and 33 deletions

View file

@ -18,7 +18,7 @@ pub mod prelude {
pub use crate::{ pub use crate::{
middleware::{SignatureVerified, VerifySignature}, middleware::{SignatureVerified, VerifySignature},
verify::Unverified, verify::Unverified,
Config, Sign, SignatureVerify, Verify, VerifyError, Config, Sign, SignatureVerify, VerifyError,
}; };
#[cfg(feature = "digest")] #[cfg(feature = "digest")]
@ -29,17 +29,18 @@ pub mod prelude {
pub use actix_web::http::header::{InvalidHeaderValue, ToStrError}; pub use actix_web::http::header::{InvalidHeaderValue, ToStrError};
} }
pub mod verify; pub mod verify {
pub use http_signature_normalization::verify::{
Algorithm, DeprecatedAlgorithm, ParseSignatureError, ParsedHeader, Unvalidated, Unverified,
ValidateError,
};
}
use self::{ use self::{
create::Unsigned, create::Unsigned,
verify::{Algorithm, Unverified}, verify::{Algorithm, Unverified},
}; };
pub trait Verify {
fn begin_verify(&self, config: &Config) -> Result<Unverified, VerifyError>;
}
pub trait SignatureVerify { pub trait SignatureVerify {
type Error: actix_web::ResponseError; type Error: actix_web::ResponseError;
type Future: IntoFuture<Item = bool, Error = Self::Error>; type Future: IntoFuture<Item = bool, Error = Self::Error>;

View file

@ -1,27 +0,0 @@
use actix_web::{dev::ServiceRequest, HttpRequest};
pub use http_signature_normalization::verify::{
Algorithm, DeprecatedAlgorithm, ParseSignatureError, ParsedHeader, Unvalidated, Unverified,
ValidateError,
};
use crate::{Config, Verify, VerifyError};
impl Verify for HttpRequest {
fn begin_verify(&self, config: &Config) -> Result<Unverified, VerifyError> {
config.begin_verify(
self.method(),
self.uri().path_and_query(),
self.headers().clone(),
)
}
}
impl Verify for ServiceRequest {
fn begin_verify(&self, config: &Config) -> Result<Unverified, VerifyError> {
config.begin_verify(
self.method(),
self.uri().path_and_query(),
self.headers().clone(),
)
}
}