# ParTCP Server
ParTCP server is a platform for conducting democratic decision making
processes. This is beta software right now, so expect errors and missing
features.
Technical documentation (in German only) can be found [here][1].
[1]: https://partcp.codeberg.page
## System requirements
- Linux
- OpenSSL
- Apache2 with headers module
- PHP 8 with OpenSSL support and sodium extension
- Git (for convenient installation and upgrading only)
## Installation (for testing environments only, not for production use!)
The following instructions assume that the root directory of your web server
is `/var/www/my-partcp.org`, that the address is `my-partcp.org` and that
the web server process is running as user `www-data`.
1. **Clone project to your web server (as root)**
```sh
$ cd /var/www
$ sudo git clone https://codeberg.org/ParTCP/partcp-server.git
$ sudo mv partcp-server my-partcp.org
```
2. **Make all files and directories accessible for all users**
```sh
$ cd my-partcp.org
$ sudo find . -type f -exec chmod 644 {} \;
$ sudo find . -type d -exec chmod 755 {} \;
```
3. **Create a directory for storing server keys**
```sh
$ sudo mkdir /etc/partcp
$ sudo chown www-data /etc/partcp
$ sudo chmod 700 /etc/partcp
```
4. **Create a directory for data storage**
```sh
$ sudo mkdir /var/www/my-partcp.org/data
$ sudo chown www-data /var/www/my-partcp.org/data
$ sudo chmod 755 /var/www/my-partcp.org/data
```
5. **Adapt Apache configuration for ParTCP root directory**
```apache
# Make resources accessible regardless of client domain
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "Origin, Content-Type, Cookie, Accept, Authorization, Access-Control-Allow-Origin, User-Agent"
# Enable auto indexing and other options
Options Indexes FollowSymLinks MultiViews
# Auto index even if index file is present, and show hidden items
DirectoryIndex disabled
IndexIgnoreReset On
# Have browsers handle YAML and Markdown files like plain text files
AddType text/plain yaml md
AddDefaultCharset utf-8
# Let all POST requests be handled by process.php script
RewriteEngine on
RewriteCond %{THE_REQUEST} ^POST [NC]
RewriteRule .* process.php
# Do not execute PHP scripts in subdirectories, deliver them as plain text instead
php_flag engine off
AddType text/plain php
AddDefaultCharset utf-8
```
6. **Reload Apache configuration**
```sh
$ sudo systemctl reload apache2
```
7. **Create and edit configuration file**
```sh
$ sudo cp config-example.php config.php
$ sudo nano config.php
```
Adapt configuration parameters to your needs and finish editing by
pressing ``, ``, ``.
8. **Send test message**
Check if the server works properly by sending a "ping" message
from your local machine:
```sh
$ curl -d "Message-Type: ping" my-partcp.org
```
You should receive a response like this:
```yaml
Signature: WHM08/cytInHm2h4z64J1pUjNg2U88B1q1ovZA5ETxSkJYhJQuKjn2RoA9X6k5Y2HCOTrrVcfRpk6/agk8trAg==
From: my-partcp.org
Date: 2021-03-30T09:06:56+02:00
Message-Type: receipt
Original-Message: 'Message-Type: ping'
Verification-Result: missing signature, nothing to verify
Public-Key: >
8BbYgAcG4yPfKKhh64+uo/AxV0NkcxhIAmnnHq1aAosBJQqBJk1Fy6Hj3g6vsZxOv4W/gN4NwzLTIGerDMNxHg==
Elapsed-Time: 0.585 ms
```
## Setting up a root account
1. **Install ParTCP command line client on your local machine.**
https://codeberg.org/ParTCP/partcp-cli
2. **Create local identity.**
```sh
$ partcp create_id root@my-partcp.org
```
3. **Create random string as credential for key submission.**
```sh
$ export credential=`openssl rand -base64 12`
```
4. **Generate credential hash code.**
```sh
$ echo -n $credential | sha256sum
```
Copy output to clipboard.
5. **Register participant on the server.**
Compose `From` and `Participant-Id` elements from identity created in step 2.
````sh
$ partcp send
To: my-partcp.org
From: root@my-partcp.org
Message-Type: registration
Participant-Id: root
Credential:
````
6. **Submit the public key of the new identity to the server.**
Use random string from step 3 here.
````sh
$ partcp submit_key root@my-partcp.org $credential
````
7. **Appoint participant as root admin.**
````sh
$ partcp send
To: my-partcp.org
From: root@my-partcp.org
Message-Type: root-appointment
Participant-Id: root
````