From 8697413adbc28fa644cd95cd68367866eb6f18c8 Mon Sep 17 00:00:00 2001 From: asonix Date: Mon, 28 Nov 2022 18:13:40 -0600 Subject: [PATCH] Rename PrivateKey to VerifyKey --- .../examples/server.rs | 34 +++++++++---------- .../src/lib.rs | 8 ++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/http-signature-normalization-actix-extractor/examples/server.rs b/http-signature-normalization-actix-extractor/examples/server.rs index 269f237..9330f78 100644 --- a/http-signature-normalization-actix-extractor/examples/server.rs +++ b/http-signature-normalization-actix-extractor/examples/server.rs @@ -1,6 +1,6 @@ use actix_web::{http::StatusCode, web, App, HttpRequest, HttpResponse, HttpServer, ResponseError}; use http_signature_normalization_actix_extractor::{ - Algorithm, Config, ConfigGenerator, PrivateKey, Signed, + Algorithm, Config, ConfigGenerator, Signed, VerifyKey, }; use sha2::Sha256; @@ -23,17 +23,29 @@ async fn protected(signed_request: Signed) -> &'static pub struct Cfg; +#[derive(Debug)] +pub struct Key; + +#[derive(Debug, thiserror::Error)] +pub enum MyError { + #[error("Unsupported algorithm")] + Algorithm, + + #[error("Couldn't decode signature")] + Decode, + + #[error("Invalid key")] + Key, +} + impl ConfigGenerator for Cfg { fn config() -> Config { Config::new().require_header("accept") } } -#[derive(Debug)] -pub struct Key; - #[async_trait::async_trait(?Send)] -impl PrivateKey for Key { +impl VerifyKey for Key { type Error = MyError; async fn init( @@ -65,18 +77,6 @@ impl PrivateKey for Key { } } -#[derive(Debug, thiserror::Error)] -pub enum MyError { - #[error("Unsupported algorithm")] - Algorithm, - - #[error("Couldn't decode signature")] - Decode, - - #[error("Invalid key")] - Key, -} - impl ResponseError for MyError { fn status_code(&self) -> StatusCode { StatusCode::BAD_REQUEST diff --git a/http-signature-normalization-actix-extractor/src/lib.rs b/http-signature-normalization-actix-extractor/src/lib.rs index 1959fbf..874075f 100644 --- a/http-signature-normalization-actix-extractor/src/lib.rs +++ b/http-signature-normalization-actix-extractor/src/lib.rs @@ -5,8 +5,8 @@ pub use actix_web_lab::extract::RequestSignature; pub use http_signature_normalization::{verify::Algorithm, Config}; -pub type Signed = - RequestSignature>; +pub type Signed = + RequestSignature>; #[cfg(feature = "sha-2")] mod sha2_digest; @@ -93,7 +93,7 @@ pub trait ConfigGenerator { } #[async_trait::async_trait(?Send)] -pub trait PrivateKey: Sized + Send { +pub trait VerifyKey: Sized + Send { type Error: Into; async fn init( @@ -118,7 +118,7 @@ impl actix_web_lab::extract::RequestSignatureScheme for SignatureScheme where C: ConfigGenerator, D: VerifyDigest, - K: PrivateKey, + K: VerifyKey, { type Signature = Signature;