dev
This commit is contained in:
parent
420cb7957a
commit
1082b89b61
3 changed files with 27 additions and 24 deletions
22
Cargo.toml
22
Cargo.toml
|
|
@ -10,22 +10,22 @@ documentation = "https://docs.rs/activitypub_federation/"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4.31", features = ["clock"], default-features = false }
|
chrono = { version = "0.4.31", features = ["clock"], default-features = false }
|
||||||
serde = { version = "1.0.189", features = ["derive"] }
|
serde = { version = "1.0.193", features = ["derive"] }
|
||||||
async-trait = "0.1.74"
|
async-trait = "0.1.74"
|
||||||
url = { version = "2.4.1", features = ["serde"] }
|
url = { version = "2.5.0", features = ["serde"] }
|
||||||
serde_json = { version = "1.0.107", features = ["preserve_order"] }
|
serde_json = { version = "1.0.108", features = ["preserve_order"] }
|
||||||
reqwest = { version = "0.11.22", features = ["json", "stream"] }
|
reqwest = { version = "0.11.22", features = ["json", "stream"] }
|
||||||
reqwest-middleware = "0.2.3"
|
reqwest-middleware = "0.2.4"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
base64 = "0.21.5"
|
base64 = "0.21.5"
|
||||||
openssl = "0.10.57"
|
openssl = "0.10.60"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
http = "0.2.9"
|
http = "0.2.11"
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
thiserror = "1.0.50"
|
thiserror = "1.0.50"
|
||||||
derive_builder = "0.12.0"
|
derive_builder = "0.12.0"
|
||||||
itertools = "0.11.0"
|
itertools = "0.12.0"
|
||||||
dyn-clone = "1.0.14"
|
dyn-clone = "1.0.16"
|
||||||
enum_delegate = "0.2.0"
|
enum_delegate = "0.2.0"
|
||||||
httpdate = "1.0.3"
|
httpdate = "1.0.3"
|
||||||
http-signature-normalization-reqwest = { version = "0.10.0", default-features = false, features = [
|
http-signature-normalization-reqwest = { version = "0.10.0", default-features = false, features = [
|
||||||
|
|
@ -35,14 +35,14 @@ http-signature-normalization-reqwest = { version = "0.10.0", default-features =
|
||||||
] }
|
] }
|
||||||
http-signature-normalization = "0.7.0"
|
http-signature-normalization = "0.7.0"
|
||||||
bytes = "1.5.0"
|
bytes = "1.5.0"
|
||||||
futures-core = { version = "0.3.28", default-features = false }
|
futures-core = { version = "0.3.29", default-features = false }
|
||||||
pin-project-lite = "0.2.13"
|
pin-project-lite = "0.2.13"
|
||||||
activitystreams-kinds = "0.3.0"
|
activitystreams-kinds = "0.3.0"
|
||||||
regex = { version = "1.10.2", default-features = false, features = [
|
regex = { version = "1.10.2", default-features = false, features = [
|
||||||
"std",
|
"std",
|
||||||
"unicode-case",
|
"unicode-case",
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1.33.0", features = [
|
tokio = { version = "1.34.0", features = [
|
||||||
"sync",
|
"sync",
|
||||||
"rt",
|
"rt",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
|
|
@ -69,7 +69,7 @@ axum = ["dep:axum", "dep:tower", "dep:hyper"]
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.1"
|
||||||
tower-http = { version = "*", features = ["map-request-body", "util"] }
|
tower-http = { version = "*", features = ["map-request-body", "util"] }
|
||||||
axum = { git = "https://github.com/tokio-rs/axum.git", rev = "30afe97e99303fffc4bf2f411a93022b5bc1ba35", features = [
|
axum = { git = "https://github.com/tokio-rs/axum.git", rev = "30afe97e99303fffc4bf2f411a93022b5bc1ba35", features = [
|
||||||
"http1",
|
"http1",
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,10 @@ async fn fetch_object_http_with_accept<T: Clone, Kind: DeserializeOwned>(
|
||||||
config.verify_url_valid(url).await?;
|
config.verify_url_valid(url).await?;
|
||||||
info!("Fetching remote object {}", url.to_string());
|
info!("Fetching remote object {}", url.to_string());
|
||||||
|
|
||||||
let counter = data.request_counter.fetch_add(1, Ordering::SeqCst);
|
// let counter = data.request_counter.fetch_add(1, Ordering::SeqCst);
|
||||||
if counter > config.http_fetch_limit {
|
// if counter > config.http_fetch_limit {
|
||||||
return Err(Error::RequestLimit);
|
// return Err(Error::RequestLimit);
|
||||||
}
|
// }
|
||||||
|
|
||||||
let req = config
|
let req = config
|
||||||
.client
|
.client
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ use crate::{
|
||||||
use base64::{engine::general_purpose::STANDARD as Base64, Engine};
|
use base64::{engine::general_purpose::STANDARD as Base64, Engine};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use http::{header::HeaderName, uri::PathAndQuery, HeaderValue, Method, Uri};
|
use http::{header::HeaderName, uri::PathAndQuery, HeaderValue, Method, Uri};
|
||||||
use http_signature_normalization_reqwest::prelude::{Config, SignExt};
|
use http_signature_normalization_reqwest::{
|
||||||
|
prelude::{Config, SignExt},
|
||||||
|
DefaultSpawner,
|
||||||
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use openssl::{
|
use openssl::{
|
||||||
hash::MessageDigest,
|
hash::MessageDigest,
|
||||||
|
|
@ -83,7 +86,8 @@ pub(crate) async fn sign_request(
|
||||||
private_key: PKey<Private>,
|
private_key: PKey<Private>,
|
||||||
http_signature_compat: bool,
|
http_signature_compat: bool,
|
||||||
) -> Result<Request, Error> {
|
) -> Result<Request, Error> {
|
||||||
static CONFIG: Lazy<Config> = Lazy::new(|| Config::new().set_expiration(EXPIRES_AFTER));
|
static CONFIG: Lazy<Config<DefaultSpawner>> =
|
||||||
|
Lazy::new(|| Config::new().set_expiration(EXPIRES_AFTER));
|
||||||
static CONFIG_COMPAT: Lazy<Config> = Lazy::new(|| {
|
static CONFIG_COMPAT: Lazy<Config> = Lazy::new(|| {
|
||||||
Config::new()
|
Config::new()
|
||||||
.mastodon_compat()
|
.mastodon_compat()
|
||||||
|
|
@ -209,13 +213,12 @@ fn verify_signature_inner(
|
||||||
Ok(verifier.verify(&base64_decoded)?)
|
Ok(verifier.verify(&base64_decoded)?)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
if verified {
|
||||||
|
debug!("verified signature for {}", uri);
|
||||||
Ok(())
|
Ok(())
|
||||||
// if verified {
|
} else {
|
||||||
// debug!("verified signature for {}", uri);
|
Err(ActivitySignatureInvalid)
|
||||||
// Ok(())
|
}
|
||||||
// } else {
|
|
||||||
// Err(ActivitySignatureInvalid)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue