Package: django-activitypub
This is an reusable Django app implementing theActivityPubprotocol with
the intent of allowing any Django project to be federated with other ActivityPub-compliant servers.It currently provides:Models for ActivityPub objects and associated admin interfaceView implementations for serving the ActivityPub protocol APIHelpers for rendering ActivityPub interactions in Django templates@Mention parsing and auto-linking in content modelsCurrent StatusThis project is in the early stages of development. It is not yet ready for production use. The API is likely to change,
security issues are likely to be present, and there are many missing features. That said, it is usable for testing and
experimentation. The maintainer of the libray is using it for their ownwebsite.WarningThis is alpha-quality software without significant production usage. It has not been security reviewed.
It is not recommended for production use.Supported ActivityPub features:Webfingerendpoint and discovery (both acct adn http(s) URIs)One or more local actors (paired with your User model) with outbox and followers collectionsLocal actor inbox supports Follow, Like, Announce, Create, and Undo [Follow, Like, Announce]Delivery of activities to local actor followersRoadmap:Signing of incoming and outgoing GET requestsSupport for other ActivityPub object types (Article, Image, Video, etc.)Support background processing of incoming activitiesSupport background delivery of outgoing activitiesQuick StartInstall django-activitypub:pipinstalldjango-activitypubAdd “django_activitypub” to your INSTALLED_APPS setting like this:INSTALLED_APPS=[...,'django_activitypub',]Include the django_activitpub URLconf in your project urls.py like this:path('',include('django_activitypub.urls')),# this can be customized laterRunpython manage.py migrateto create the activitypub models.Create instances ofLocalActorfor your user profiles:fromdjango.contrib.authimportget_user_modelfromdjango_activitypub.modelsimportLocalActoruser=get_user_model().objects.get(username='myuser')LocalActor.objects.create(user=user,name=user.username,preferred_username=user.username)Publish your content by creating a note:fromdjango_activitypub.modelsimportLocalActor,NoteclassMyModel(models.Model):# ... your model fieldsdefpublish(self,base_uri):actor=LocalActor.objects.get(user=self.author)Note.objects.upsert(base_uri=base_uri,local_actor=actor,content=self.formatted_content(),content_url=f'{base_uri}{self.get_absolute_url()}')Start the development server and check the ActivityPub URLs:pythonmanage.pyrunserverhttpgethttp://127.0.0.1:8000/pub/myuserAccept:application/activity+jsonYou can also use the Django Admin to create new Notes and LocalActors.SecurityCurrently there is a fairly bare-bone approach to security, implementing the the minimum required to successfully
communicate with other ActivityPub servers and protect library integrators from common attacks.HTTP POST requests to the inbox are currently verifiedHTTP POST requests to follower inboxes are signed by a local per-user key stored in the databaseWhen remote content is displayed in a template, the content is sanitized or escapedPlease send any security issues immediately to the maintainer:security@steamboatlabs.comInteroperabilityVerified interoperability with:✅ Mastodon❓PleromaOthers