Log signer ID when processing incoming activity
This commit is contained in:
parent
0ec69adbe2
commit
a0c0f1d092
2 changed files with 8 additions and 4 deletions
|
@ -99,8 +99,9 @@ async fn inbox(
|
|||
} else {
|
||||
log::info!("received in {}: {}", request.uri().path(), activity);
|
||||
};
|
||||
if let Err(err) = signature_verified {
|
||||
log::warn!("invalid signature: {}", err);
|
||||
match signature_verified {
|
||||
Ok(signer_id) => log::info!("activity signed by {}", signer_id),
|
||||
Err(err) => log::warn!("invalid signature: {}", err),
|
||||
};
|
||||
receive_activity(&config, &db_pool, activity.into_inner()).await?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
|
|
|
@ -108,11 +108,12 @@ fn parse_http_signature(
|
|||
Ok(signature_data)
|
||||
}
|
||||
|
||||
/// Verifies HTTP signature and returns signer ID
|
||||
pub async fn verify_http_signature(
|
||||
config: &Config,
|
||||
db_pool: &Pool,
|
||||
request: &HttpRequest,
|
||||
) -> Result<(), VerificationError> {
|
||||
) -> Result<String, VerificationError> {
|
||||
let signature_data = parse_http_signature(
|
||||
request.method(),
|
||||
request.uri(),
|
||||
|
@ -151,7 +152,9 @@ pub async fn verify_http_signature(
|
|||
if !is_valid_signature {
|
||||
return Err(VerificationError::InvalidSignature);
|
||||
}
|
||||
Ok(())
|
||||
let signer_id = actor_profile.actor_id(&config.instance_url())
|
||||
.map_err(|_| VerificationError::ActorError("invalid profile".to_string()))?;
|
||||
Ok(signer_id)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue