LemmyNet / activitypub-federation-rust

High-level Rust library for the Activitypub protocol
GNU Affero General Public License v3.0
420 stars 45 forks source link

Secure mode federation support (WIP) #39

Closed Alexis211 closed 1 year ago

Alexis211 commented 1 year ago

This is a first iteration of my work aiming at adding support for so-called "secure-mode federation" (#35) (see Mastodon documentation). The following features are added:

Open questions:

Nutomic commented 1 year ago

Mastodon itself uses a dedicated system actor to sign such HTTP requests.

Based on this line from the Mastodon docs, a different approach would make sense: Add an optional field signed_fetch_key (or however you want to call it) to FederationConfig. If that field is set, sign all outgoing requests with the given key. Then it wouldnt be necessary to add extra fetch methods or pass additional arguments all over your code. Using a single key for all users is also better for privacy.

By the way have you already tested that this is compatible with Mastodon?

@darrinsmart Maybe you can also have a look.

Alexis211 commented 1 year ago

Based on this line from the Mastodon docs, a different approach would make sense: Add an optional field signed_fetch_key (or however you want to call it) to FederationConfig. If that field is set, sign all outgoing requests with the given key. Then it wouldnt be necessary to add extra fetch methods or pass additional arguments all over your code. Using a single key for all users is also better for privacy.

Thanks, it makes sense. I will try implementing that instead.

By the way have you already tested that this is compatible with Mastodon?

I have not. I don't run a Mastodon server, and I don't have time to spawn one to test this feature (I'm doing this PR because I need it for a new activitypub server thing, not for Mastodon compatibility). If you know the address of an existing Mastodon server that has secure mode enabled, I can test outgoing requests to that server.

Nutomic commented 1 year ago

Looks good! Some minor notes and clippy is failing in CI.

If you can test against another platform besides Mastodon thats also good. However I dont have such a server either. I just want to avoid an incompatible implementation in the wild which could make things complicated in the future. How about we leave this PR open until someone can test it? Anyway there wouldnt be many other changes to create conflicts.

Alexis211 commented 1 year ago

How about we leave this PR open until someone can test it?

LGTM

darrinsmart commented 1 year ago

Apologies for the late reply - I don't have much spare time at the moment.

It was a very minimal test, but I was able to dereference my Gotosocial account with Alex's change - so looks good from here too!

Nutomic commented 1 year ago

Great, thanks!