Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelrobert committed Mar 28, 2024
1 parent a80d165 commit 214f42d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ tower-http = { version = "0.5", features = ["trace"] }
trace = "0.1"
privacypass = { git = "https://github.com/raphaelrobert/privacypass" }
async-trait = "0.1"
base64 = "0.21"
base64 = "0.22"
actix-web = "4.4"
futures-util = "0.3.24"
http = "1"

[dev-dependencies]
reqwest = "0.11"
reqwest = "0.12"
4 changes: 2 additions & 2 deletions src/actix_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use privacypass::{
authenticate::{build_www_authenticate_header, TokenChallenge},
authorize::parse_authorization_header,
},
batched_tokens::{
batched_tokens_ristretto255::{
server::{serialize_public_key, BatchedKeyStore},
TokenRequest,
},
Expand Down Expand Up @@ -155,7 +155,7 @@ where

pub(crate) fn challenge(uri: &http::Uri) -> TokenChallenge {
TokenChallenge::new(
privacypass::TokenType::Batched,
privacypass::TokenType::BatchedTokenRistretto255,
&uri.to_string(),
None,
&[uri.to_string()],
Expand Down
4 changes: 2 additions & 2 deletions src/axum_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use privacypass::{
authenticate::{build_www_authenticate_header, TokenChallenge},
authorize::parse_authorization_header,
},
batched_tokens::{
batched_tokens_ristretto255::{
server::{serialize_public_key, BatchedKeyStore},
TokenRequest,
},
Expand Down Expand Up @@ -114,7 +114,7 @@ where

pub(crate) fn challenge(uri: &Uri) -> TokenChallenge {
TokenChallenge::new(
privacypass::TokenType::Batched,
privacypass::TokenType::BatchedTokenRistretto255,
&uri.to_string(),
None,
&[uri.to_string()],
Expand Down
2 changes: 1 addition & 1 deletion src/memory_stores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
use tokio::sync::Mutex;

use privacypass::{
batched_tokens::{server::*, *},
batched_tokens_ristretto255::{server::*, *},
Nonce, NonceStore,
};

Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

use async_trait::async_trait;
use privacypass::batched_tokens::server::Server;
use privacypass::batched_tokens_ristretto255::server::Server;

use tokio::sync::Mutex;

use privacypass::{
batched_tokens::{server::*, *},
batched_tokens_ristretto255::{server::*, *},
NonceStore, Serialize,
};

Expand Down
14 changes: 4 additions & 10 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,24 @@
use std::str::FromStr;

pub fn header_name_to_http10(
header_name: actix_web::http::header::HeaderName,
) -> http::header::HeaderName {
http::header::HeaderName::from_str(header_name.as_str()).unwrap()
}

pub fn header_value_to_http10(
pub(crate) fn header_value_to_http10(
header_value: actix_web::http::header::HeaderValue,
) -> http::header::HeaderValue {
http::header::HeaderValue::from_str(header_value.to_str().unwrap()).unwrap()
}

pub fn header_name_to_http02(
pub(crate) fn header_name_to_http02(
header_name: http::header::HeaderName,
) -> actix_web::http::header::HeaderName {
actix_web::http::header::HeaderName::from_str(header_name.as_str()).unwrap()
}

pub fn header_value_to_http02(
pub(crate) fn header_value_to_http02(
header_value: http::header::HeaderValue,
) -> actix_web::http::header::HeaderValue {
actix_web::http::header::HeaderValue::from_str(header_value.to_str().unwrap()).unwrap()
}

pub fn uri_to_http10(uri: &actix_web::http::Uri) -> http::Uri {
pub(crate) fn uri_to_http10(uri: &actix_web::http::Uri) -> http::Uri {
http::Uri::from_str(uri.to_string().as_str()).unwrap()
}
16 changes: 5 additions & 11 deletions tests/actix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later

use actix_web::{
http::{self, header::HeaderValue, StatusCode},
rt, web, App, HttpResponse, HttpServer, Responder,
};
use actix_web::{rt, web, App, HttpResponse, HttpServer, Responder};
use http::{HeaderValue, StatusCode};
use privacypass::{
auth::{authenticate::parse_www_authenticate_header, authorize::build_authorization_header},
batched_tokens::{server::*, TokenResponse},
batched_tokens_ristretto255::{server::*, TokenResponse},
Serialize,
};
use privacypass_middleware::{
actix_middleware::*,
memory_stores::{MemoryKeyStore, MemoryNonceStore},
state::PrivacyPassState,
utils::{header_name_to_http02, header_value_to_http02, header_value_to_http10},
};
use std::{sync::Arc, thread};

Expand Down Expand Up @@ -80,7 +77,7 @@ async fn full_cycle_actix() {

// Extract token challenge from header
let header_name = http::header::WWW_AUTHENTICATE;
let header_value = header_value_to_http10(res.headers().get(header_name).unwrap().clone());
let header_value = res.headers().get(header_name).unwrap().clone();

assert_eq!(res.bytes().await.unwrap().len(), 0);

Expand All @@ -93,7 +90,7 @@ async fn full_cycle_actix() {
// Instantiate the Privacy Pass client
let public_key = deserialize_public_key(challenge.token_key()).unwrap();

let client = privacypass::batched_tokens::client::Client::new(public_key);
let client = privacypass::batched_tokens_ristretto255::client::Client::new(public_key);

assert_eq!(challenge.max_age(), None);

Expand Down Expand Up @@ -129,9 +126,6 @@ async fn full_cycle_actix() {
// Redeem a token
let (header_name, header_value) = build_authorization_header(&tokens[0]).unwrap();

let header_name = header_name_to_http02(header_name);
let header_value = header_value_to_http02(header_value);

let res = http_client
.get("http://localhost:3001/origin")
.header(header_name.clone(), header_value.clone())
Expand Down
10 changes: 3 additions & 7 deletions tests/axum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ use axum::{
};
use privacypass::{
auth::{authenticate::parse_www_authenticate_header, authorize::build_authorization_header},
batched_tokens::{server::*, TokenResponse},
batched_tokens_ristretto255::{server::*, TokenResponse},
Serialize,
};
use privacypass_middleware::{
axum_middleware::*,
memory_stores::{MemoryKeyStore, MemoryNonceStore},
state::PrivacyPassState,
utils::{header_name_to_http02, header_value_to_http02, header_value_to_http10},
};
use reqwest::{
header::{HeaderValue, CONTENT_TYPE},
Expand Down Expand Up @@ -79,7 +78,7 @@ async fn full_cycle_axum() {

// Extract token challenge from header
let header_name = reqwest::header::WWW_AUTHENTICATE;
let header_value = header_value_to_http10(res.headers().get(header_name).unwrap().clone());
let header_value = res.headers().get(header_name).unwrap().clone();

assert_eq!(res.bytes().await.unwrap().len(), 0);

Expand All @@ -92,7 +91,7 @@ async fn full_cycle_axum() {
// Instantiate the Privacy Pass client
let public_key = deserialize_public_key(challenge.token_key()).unwrap();

let client = privacypass::batched_tokens::client::Client::new(public_key);
let client = privacypass::batched_tokens_ristretto255::client::Client::new(public_key);

assert_eq!(challenge.max_age(), None);

Expand Down Expand Up @@ -128,9 +127,6 @@ async fn full_cycle_axum() {
// Redeem a token
let (header_name, header_value) = build_authorization_header(&tokens[0]).unwrap();

let header_name = header_name_to_http02(header_name);
let header_value = header_value_to_http02(header_value);

let res = http_client
.get("http://localhost:3000/origin")
.header(header_name.clone(), header_value.clone())
Expand Down

0 comments on commit 214f42d

Please sign in to comment.