mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-06-08 16:29:33 +00:00
chore: more clippy lints
This commit is contained in:
parent
bec8d0bac5
commit
605d8cc60b
|
@ -35,7 +35,7 @@ actix-rt = { version = "2.7.0" }
|
|||
|
||||
actix-web = { version = "4.2.1", default-features = false, optional = true }
|
||||
http-signature-normalization-actix = { version = "0.6.1", default-features = false, features = ["server", "sha-2"], optional = true }
|
||||
axum = { version = "0.6.0-rc.5", features = ["json", "headers", "macros", "original-uri"], optional = true }
|
||||
axum = { version = "0.6.0", features = ["json", "headers", "macros", "original-uri"], optional = true }
|
||||
|
||||
# Axum
|
||||
tower-http = { version = "0.3", features = ["map-request-body", "util", "trace"], optional = true }
|
||||
|
|
|
@ -132,13 +132,9 @@ async fn http_get_user(
|
|||
|
||||
let user = ObjectId::<MyUser>::new(url)
|
||||
.dereference_local(&data)
|
||||
.await
|
||||
.expect("Failed to dereference user");
|
||||
|
||||
let user = user
|
||||
.await?
|
||||
.into_apub(&data)
|
||||
.await
|
||||
.expect("Failed to convert to apub user");
|
||||
.await?;
|
||||
|
||||
Ok(ApubJson(WithContext::new_default(user)))
|
||||
}
|
||||
|
|
|
@ -37,22 +37,30 @@ async fn verify_payload(request: Request<BoxBody>) -> Result<Request<BoxBody>, R
|
|||
.await
|
||||
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response())?;
|
||||
|
||||
let Some(digest) = parts.headers.get("Digest") else {
|
||||
return Err((StatusCode::UNAUTHORIZED, "Missing digest header".to_string()).into_response());
|
||||
};
|
||||
|
||||
let Some(digests) = DigestPart::try_from_header(digest) else {
|
||||
return Err((StatusCode::UNAUTHORIZED, "Malformed digest header".to_string()).into_response());
|
||||
};
|
||||
|
||||
if !verify_sha256(&digests, bytes.as_ref()) {
|
||||
Err((
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Digest does not match payload".to_string(),
|
||||
match parts.headers.get("Digest") {
|
||||
None => Err((
|
||||
StatusCode::UNAUTHORIZED,
|
||||
"Missing digest header".to_string(),
|
||||
)
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(Request::from_parts(parts, body::boxed(Full::from(bytes))))
|
||||
.into_response()),
|
||||
Some(digest) => match DigestPart::try_from_header(digest) {
|
||||
None => Err((
|
||||
StatusCode::UNAUTHORIZED,
|
||||
"Malformed digest header".to_string(),
|
||||
)
|
||||
.into_response()),
|
||||
Some(digests) => {
|
||||
if !verify_sha256(&digests, bytes.as_ref()) {
|
||||
Err((
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Digest does not match payload".to_string(),
|
||||
)
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(Request::from_parts(parts, body::boxed(Full::from(bytes))))
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue