2019-07-04 20:50:46 +00:00
< img src = "https://code.freedombone.net/bashrc/epicyon/raw/master/img/logo.png?raw=true" width = 256/ >
2019-07-04 21:20:26 +00:00
A minimal ActivityPub server.
2019-06-28 18:55:29 +00:00
2019-06-29 10:08:59 +00:00
Based on the specification: https://www.w3.org/TR/activitypub
2019-06-29 21:13:44 +00:00
2019-06-29 11:47:33 +00:00
Also: https://raw.githubusercontent.com/w3c/activitypub/gh-pages/activitypub-tutorial.txt
2019-06-29 10:08:59 +00:00
2019-07-05 20:32:21 +00:00
https://blog.dereferenced.org/what-is-ocap-and-why-should-i-care
2019-07-06 17:00:22 +00:00
https://alexcastano.com/what-is-activity-pub
2019-07-04 21:32:18 +00:00
This project is currently *pre alpha* and not recommended for any real world uses.
2019-07-04 21:21:10 +00:00
## Goals
2019-07-04 21:20:26 +00:00
* A minimal ActivityPub server, comparable to an email MTA.
2019-07-04 21:40:30 +00:00
* AGPLv3+
2019-07-04 21:20:26 +00:00
* Server-to-server and client-to-server protocols supported.
2019-07-04 21:32:18 +00:00
* Implemented in a common language (Python 3)
2019-07-04 22:11:56 +00:00
* Keyword filtering.
2019-07-14 13:50:31 +00:00
* Being able to build crowdsouced organizations with roles and skills
2019-07-06 09:07:24 +00:00
* Sharings collection, similar to the gnusocial sharings plugin
2019-07-15 09:37:59 +00:00
* Quotas for received posts per day, per domain and per account
* Hellthread detection and removal
2019-07-04 21:20:26 +00:00
* Support content warnings, reporting and blocking.
* http signatures and basic auth.
* Compatible with http (onion addresses), https and dat.
* Minimal dependencies.
2019-07-05 20:32:21 +00:00
* Capabilities based security
2019-07-14 11:30:15 +00:00
* Support image blurhashes
2019-07-04 21:20:26 +00:00
* Data minimization principle. Configurable post expiry time.
2019-07-12 12:47:06 +00:00
* Likes and repeats only visible to authorized viewers
2019-07-14 11:30:15 +00:00
* ReplyGuy mitigation - maxmimum replies per post or posts per day
2019-07-14 09:17:50 +00:00
* Ability to delete or hide specific conversation threads
2019-07-04 21:20:26 +00:00
* Commandline interface. If there's a GUI it should be a separate project.
* Designed for intermittent connectivity. Assume network disruptions.
2019-07-19 08:52:10 +00:00
* Limited visibility of follows/followers
2019-07-04 21:20:26 +00:00
* Suitable for single board computers.
2019-06-28 18:55:29 +00:00
## Install
2019-07-13 13:39:52 +00:00
On Arch/Parabola:
2019-06-28 18:55:29 +00:00
``` bash
2019-07-12 19:08:46 +00:00
sudo pacman -S tor python-pip python-pysocks python-pycryptodome python-beautifulsoup4 imagemagick python-pillow python-numpy
2019-07-02 17:11:59 +00:00
sudo pip install commentjson
2019-07-04 20:44:03 +00:00
```
2019-07-13 13:39:52 +00:00
Or on Debian:
``` bash
sudo apt-get -y install tor python3-pip python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-pil.imagetk
sudo pip3 install commentjson beautifulsoup4 pycryptodome
```
2019-07-04 20:44:03 +00:00
## Running Tests
To run the unit tests:
``` bash
python3 epicyon.py --tests
```
To run the network tests. These simulate instances exchanging messages.
``` bash
python3 epicyon.py --testsnetwork
```
2019-07-04 21:32:18 +00:00
2019-07-04 22:54:28 +00:00
## Account Management
2019-07-19 09:00:17 +00:00
The first thing you will need to do is to create an account. You can do this with the command:
2019-07-04 22:54:28 +00:00
``` bash
python3 epicyon.py --addaccount nickname@domain --password [yourpassword]
```
To remove an account (be careful!):
``` bash
python3 epicyon.py --rmaccount nickname@domain
```
2019-07-05 09:53:51 +00:00
To change the password for an account:
``` bash
python3 epicyon.py --changepassword nickname@domain newpassword
```
2019-07-12 14:42:43 +00:00
To set an avatar for an account:
``` bash
2019-07-12 16:03:45 +00:00
python3 epicyon.py --nickname [nick] --domain [name] --avatar [image filename]
2019-07-12 14:42:43 +00:00
```
To set the background image for an account:
``` bash
2019-07-12 16:03:45 +00:00
python3 epicyon.py --nickname [nick] --domain [name] --background [image filename]
2019-07-12 14:42:43 +00:00
```
2019-07-04 21:32:18 +00:00
## Running the Server
To run with defaults:
``` bash
python3 epicyon.py
```
In a browser of choice (but not Tor browser) you can then navigate to:
``` text
http://localhost:8085/users/admin
```
If it's working then you should see the json actor for the default admin account.
For a more realistic installation you can run on a defined domain and port:
``` bash
python3 epicyon.py --domain [name] --port 8000 --https
```
You will need to proxy port 8000 through your web server and set up CA certificates as needed.
By default data will be stored in the directory in which you run the server, but you can also specify a directory:
``` bash
python3 epicyon.py --domain [name] --port 8000 --https --path [data directory]
```
2019-07-04 21:40:30 +00:00
2019-07-19 10:13:52 +00:00
## Defining a perimeter
By default the server will federate with any others, but there may be cases where you want to limit this down to a defined set of servers within an organization.
You can specify the domains which can federate with your server with the *--federate* option.
2019-07-04 21:40:30 +00:00
``` bash
2019-07-04 21:41:23 +00:00
python3 epicyon.py --domain [name] --port 8000 --https --federate domain1.net domain2.org domain3.co.uk
2019-07-04 21:40:30 +00:00
```
2019-07-09 15:58:51 +00:00
## Following other accounts
With your server running you can then follow other accounts with:
``` bash
2019-07-17 17:55:31 +00:00
python3 epicyon.py --nickname [yournick] --domain [name] --follow othernick@domain --password [c2s password]
2019-07-09 15:58:51 +00:00
```
2019-07-17 12:31:10 +00:00
The password is for the client to obtain access to the server.
2019-07-12 20:51:02 +00:00
You may or may not need to use the *--port* , *--https* and *--tor* options, depending upon how your server was set up.
2019-07-17 12:31:10 +00:00
Unfollowing is silimar:
``` bash
2019-07-17 17:55:31 +00:00
python3 epicyon.py --nickname [yournick] --domain [name] --unfollow othernick@domain --password [c2s password]
2019-07-17 12:31:10 +00:00
```
2019-07-19 09:01:39 +00:00
## Culling follower numbers
In this system the number of followers which an account has will only be visible to the account holder. Other viewers will see a made up number. Which accounts are followed or followed by a person will also only have limited visibility.
The intention is to prevent the construction of detailed social graphs by adversaries, and to frustrate attempts to build celebrity status based on number of followers, which on sites like Twitter creates a dubious economy of fake accounts and the trading thereof.
If you are the account holder though you will be able to see exactly who you're following or being followed by.
2019-07-17 12:53:18 +00:00
## Sending posts
2019-07-17 14:43:51 +00:00
To make a public post:
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
--sendto public --message "hello" \
--warning "This is a content warning" \
2019-07-17 17:55:31 +00:00
--password [c2s password]
2019-07-17 14:43:51 +00:00
```
To post to followers only:
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
--sendto followers --message "hello" \
--warning "This is a content warning" \
2019-07-17 17:55:31 +00:00
--password [c2s password]
2019-07-17 14:43:51 +00:00
```
2019-07-17 14:46:40 +00:00
To send a post to a particular address (direct message):
2019-07-17 12:53:18 +00:00
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
--sendto othernick@domain --message "hello" \
--warning "This is a content warning" \
2019-07-17 17:55:31 +00:00
--password [c2s password]
2019-07-17 12:53:18 +00:00
```
The password is the c2s password for your account.
You can also attach an image. It must be in png, jpg or gif format.
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
--sendto othernick@domain --message "bees!" \
--warning "bee-related content" --attach bees.png \
--imagedescription "bees on flowers" \
--blurhash \
2019-07-17 17:55:31 +00:00
--password [c2s password]
2019-07-17 13:00:57 +00:00
```
2019-07-19 09:00:17 +00:00
## Viewing Public Posts
To view the public posts for a person:
``` bash
python3 epicyon.py --posts nickname@domain
```
If you want to view the raw json:
``` bash
python3 epicyon.py --postsraw nickname@domain
```
2019-07-17 17:34:52 +00:00
## Delete posts
2019-07-17 18:13:45 +00:00
To delete a post which you wrote you must first know its url. It is usually something like:
2019-07-17 17:34:52 +00:00
``` text
2019-07-17 18:13:45 +00:00
https://yourDomain/users/yourNickname/statuses/number
2019-07-17 17:34:52 +00:00
```
Once you know that they you can use the command:
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
2019-07-17 17:55:31 +00:00
--delete [url] --password [c2s password]
2019-07-17 17:34:52 +00:00
```
Deletion of posts in a federated system is not always reliable. Some instances may not implement deletion, and this may be because of the possibility of spurious deletes being sent by an adversary to cause trouble.
2019-07-17 18:13:45 +00:00
By default federated deletions are not permitted because of the potential for misuse. If you wish to enable it then set the option ** --allowdeletion**.
2019-07-17 17:51:23 +00:00
2019-07-17 18:13:45 +00:00
Another complication of federated deletion is that the followers collection may change between the time when a post was created and the time it was deleted, leaving some stranded copies.
2019-07-17 17:34:52 +00:00
2019-07-17 13:00:57 +00:00
## Announcements/repeats/boosts
To announce or repeat a post you will first need to know it's url. It is usually something like:
``` text
https://domain/users/name/statuses/number
```
Once you know that they you can use the command:
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
2019-07-17 17:55:31 +00:00
--repeat [url] --password [c2s password]
2019-07-17 12:53:18 +00:00
```
2019-07-17 18:36:29 +00:00
## Like posts
To like a post you will first need to know it's url. It is usually something like:
``` text
https://domain/users/name/statuses/number
```
Once you know that they you can use the command:
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
--like [url] --password [c2s password]
```
To subsequently undo the like:
``` bash
python3 epicyon.py --nickname [yournick] --domain [name] \
--undolike [url] --password [c2s password]
```
2019-07-12 20:51:02 +00:00
## Archiving posts
You can archive old posts with:
``` bash
python3 epicyon.py --archive [directory]
```
Which will move old posts to the given directory. You can also specify the number of weeks after which images will be archived, and the maximum number of posts within in/outboxes.
``` bash
python3 epicyon.py --archive [directory] --archiveweeks 4 --maxposts 256
```
If you want old posts to be deleted for data minimization purposes then the archive location can be set to */dev/null* .
``` bash
python3 epicyon.py --archive /dev/null --archiveweeks 4 --maxposts 256
```
2019-07-14 13:20:05 +00:00
2019-07-14 20:19:17 +00:00
## Blocking and unblocking
Whether you are using the ** --federate** option to define a set of allowed instances or not, you may want to block particular accounts even inside of the perimeter. To block an account:
``` bash
2019-07-17 22:11:03 +00:00
python3 epicyon.py --nickname yournick --domain yourdomain --block somenick@somedomain --password [c2s password]
2019-07-14 20:19:17 +00:00
```
This blocks at the earliest possble stage of receiving messages, such that nothing from the specified account will be written to your inbox.
Or to unblock:
``` bash
2019-07-17 22:11:03 +00:00
python3 epicyon.py --nickname yournick --domain yourdomain --unblock somenick@somedomain --password [c2s password]
2019-07-14 20:19:17 +00:00
```
2019-07-14 20:58:50 +00:00
## Filtering on words or phrases
Blocking based upon the content of a message containing certain words or phrases is relatively crude and not always effective, but can help to reduce unwanted communications.
To add a word or phrase to be filtered out:
``` bash
python3 epicyon.py --nickname yournick --domain yourdomain --filter "this is a filtered phrase"
```
It can also be removed with:
``` bash
python3 epicyon.py --nickname yournick --domain yourdomain --unfilter "this is a filtered phrase"
```
Like blocking, filters are per account and so different accounts on a server can have differing filter policies.
2019-07-15 10:34:24 +00:00
2019-07-15 10:54:40 +00:00
You can also combine words or phrases with "+", such that they can be present in different parts of the message:
``` bash
python3 epicyon.py --nickname yournick --domain yourdomain --filter "blockedword+some other phrase"
```
2019-07-15 10:34:24 +00:00
## Applying quotas
A common adversarial situation is that a hostile server tries to flood your shared inbox with posts in order to try to overload your system. To mitigate this it's possible to add quotas for the maximum number of received messages per domain per day and per account per day.
If you're running the server it would look like this:
``` bash
python3 epicyon.py --domainmax 1000 --accountmax 200
```
With these settings you're going to be receiving no more than 200 messages for any given account within a day.
2019-07-18 17:03:00 +00:00
## Delegated roles
Within an organization you may want to define different roles and for some projects to be delegated. By default the first account added to the system will be the admin, and be assigned *moderator* and *delegator* roles under a project called *instance* . The admin can then delegate a person to other projects with:
``` bash
python3 epicyon.py --nickname [admin nickname] --domain [mydomain] \
--delegate [person nickname] \
--project [project name] --role [title] \
--password [c2s password]
```
The other person could also be made a delegator, but they will only be able to delegate further within projects which they're assigned to. By design, this creates a restricted organizational hierarchy. For example:
``` bash
python3 epicyon.py --nickname [admin nickname] --domain [mydomain] \
--delegate [person nickname] \
--project [project name] --role delegator \
--password [c2s password]
```
A delegated role can also be removed.
``` bash
python3 epicyon.py --nickname [admin nickname] --domain [mydomain] \
--undelegate [person nickname] \
--project [project name] \
--password [c2s password]
```
2019-07-18 17:11:45 +00:00
2019-07-19 10:01:24 +00:00
This extends the ActivityPub client-to-server protocol to include activities called *Delegate* and *Role* . The json looks like:
2019-07-18 17:11:45 +00:00
``` json
{ 'type': 'Delegate',
2019-07-19 12:12:01 +00:00
'actor': https://somedomain/users/admin,
2019-07-18 17:11:45 +00:00
'object': {
'type': 'Role',
'actor': https://'+somedomain+'/users/'+other,
'object': 'otherproject;otherrole',
'to': [],
'cc': []
},
'to': [],
'cc': []}
```
2019-07-19 09:06:55 +00:00
Projects and roles are only scoped within a single instance. There presently are not enough security mechanisms to support multi-instance distributed organizations.
2019-07-19 10:01:24 +00:00
## Assigning skills
To help create organizations you can assign some skills to your account. Note that you can only assign skills to yourself and not to other people. The command is:
``` bash
python3 epicyon.py --nickname [nick] --domain [mydomain] \
--skill [tag] --level [0-100] \
--password [c2s password]
```
2019-07-19 10:04:11 +00:00
The level value is a percentage which indicates how proficient you are with that skill.
2019-07-19 10:01:24 +00:00
This extends the ActivityPub client-to-server protocol to include an activity called *Skill* . The json looks like:
``` json
{ 'type': 'Skill',
2019-07-19 12:12:01 +00:00
'actor': https://somedomain/users/somenickname,
2019-07-19 10:01:24 +00:00
'object': gardening;80,
'to': [],
'cc': []}
```
2019-07-19 11:43:17 +00:00
## Setting availability status
For the purpose of things like knowing current task status or task completion a status value can be set.
``` bash
python3 epicyon.py --nickname [nick] --domain [mydomain] \
--availability [status] \
--password [c2s password]
```
The status value can be any string, and can become part of organization building by combining it with roles and skills.
This extends the ActivityPub client-to-server protocol to include an activity called *Availability* . "Status" was avoided because of te possibility of confusion with other things. The json looks like:
``` json
{ 'type': 'Availability',
2019-07-19 12:12:01 +00:00
'actor': https://somedomain/users/somenickname,
2019-07-19 11:43:17 +00:00
'object': ready,
'to': [],
'cc': []}
```
2019-07-19 09:06:55 +00:00
## Object Capabilities Security
A description of the proposed object capabilities model [is here ](ocaps.md ).