2 use http_signature_normalization_actix::digest::middleware::VerifyDigest;
4 comment::get_apub_comment,
6 inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox},
9 APUB_JSON_CONTENT_TYPE,
11 use lemmy_utils::settings::Settings;
12 use sha2::{Digest, Sha256};
14 pub fn config(cfg: &mut web::ServiceConfig) {
15 if Settings::get().federation.enabled {
16 println!("federation enabled, host is {}", Settings::get().hostname);
17 let digest_verifier = VerifyDigest::new(Sha256::new());
22 .guard(guard::Header("Accept", APUB_JSON_CONTENT_TYPE))
24 "/c/{community_name}",
25 web::get().to(get_apub_community_http),
28 "/c/{community_name}/followers",
29 web::get().to(get_apub_community_followers),
32 "/c/{community_name}/outbox",
33 web::get().to(get_apub_community_outbox),
35 .route("/u/{user_name}", web::get().to(get_apub_user_http))
36 .route("/post/{post_id}", web::get().to(get_apub_post))
37 .route("/comment/{comment_id}", web::get().to(get_apub_comment)),
39 // Inboxes dont work with the header guard for some reason.
41 web::resource("/c/{community_name}/inbox")
42 .wrap(digest_verifier.clone())
43 .route(web::post().to(community_inbox)),
46 web::resource("/u/{user_name}/inbox")
47 .wrap(digest_verifier.clone())
48 .route(web::post().to(user_inbox)),
51 web::resource("/inbox")
52 .wrap(digest_verifier)
53 .route(web::post().to(shared_inbox)),