No description
Find a file
Paul Delafosse 9332c81458
feat: add axum compat (#12)
* feat: add actix feature flag

* (WIP)feat: add axum feature

* WIP: axum veridy digest + example

Note: this does not compile yet

* WIP

* chore: clippy lints

* Use actix rt for axum example

* ci: run example in CI for both actix and axum

* feat: add json wrapper type for axum

* docs: update readme with actix and axum feature flags

* fix: fix ci

* chore: more clippy lints

* refactor: update according to PR comment and factorize 'verify_digest'
2022-11-28 21:19:56 +00:00
examples feat: add axum compat (#12) 2022-11-28 21:19:56 +00:00
src feat: add axum compat (#12) 2022-11-28 21:19:56 +00:00
.drone.yml feat: add axum compat (#12) 2022-11-28 21:19:56 +00:00
.gitignore Use enum_delegate crate (#5) 2022-11-14 12:04:36 +00:00
.rustfmt.toml Initial commit 2022-06-02 13:26:05 +02:00
Cargo.lock feat: add axum compat (#12) 2022-11-28 21:19:56 +00:00
Cargo.toml feat: add axum compat (#12) 2022-11-28 21:19:56 +00:00
LICENSE Initial commit 2022-06-02 13:26:05 +02:00
README.md feat: add axum compat (#12) 2022-11-28 21:19:56 +00:00

Activitypub-Federation

Build Status Crates.io

A high-level framework for ActivityPub federation in Rust, extracted from Lemmy. The goal is that this library can take care of almost everything related to federation for different projects. For now it is still far away from that goal, and has many rough edges that need to be smoothed.

You can join the Matrix channel #activitystreams:asonix.dog to discuss about Activitypub in Rust.

Features

  • ObjectId type, wraps the id url and allows for type safe fetching of objects, both from database and HTTP
  • Queue for activity sending, handles HTTP signatures, retry with exponential backoff, all in background workers
  • Inbox for receiving activities, verifies HTTP signatures, performs other basic checks and helps with routing
  • Data structures for federation are defined by the user, not the library. This gives you maximal flexibility, and lets you accept only messages which your code can handle. Others are rejected automatically during deserialization.
  • Generic error type (unfortunately this was necessary)
  • various helpers for verification, (de)serialization, context etc

How to use

To get started, have a look at the API documentation and example code. You can also find some ActivityPub resources in the Lemmy documentation. If anything is unclear, please open an issue for clarification. For a more advanced implementation, take a look at the Lemmy federation code.

Currently supported frameworks include actix and axum:

actix:

activitypub_federation = { version = "*", features = ["actix"] }

axum:

activitypub_federation = { version = "*", features = ["axum"] }

Roadmap

Things to work on in the future:

  • Improve documentation and example: Some things could probably be documented better. The example code should be simplified. where possible.
  • Simplify generics: The library uses a lot of generic parameters, where clauses and associated types. It should be possible to simplify them.
  • Improve macro: The macro is implemented very badly and doesn't have any error handling.
  • Generate HTTP endpoints: It would be possible to generate HTTP endpoints automatically for each actor.
  • Support for other web frameworks: Can be implemented using feature flags if other projects require it.
  • Signed fetch: JSON can only be fetched by authenticated actors, which means that fetches from blocked instances can also be blocked. In combination with the previous point, this could be handled entirely in the library.
  • Helpers for testing: Lemmy has a pretty useful test suite which (de)serializes json from other projects, to ensure that federation remains compatible. Helpers for this could be added to the library.
  • Webfinger support: Not part of the Activitypub standard, but often used together for user discovery.
  • Remove request_counter from API: It should be handled internally and not exposed. Maybe as part of Data struct.

License

Licensed under AGPLv3.