tatey / trace_privately

A robust and fully featured key server for the TracePrivately iOS app
https://trace-privately-demo.herokuapp.com
MIT License
1 stars 0 forks source link

Key Server for TracePrivately

Deploy

A robust and fully featured key server for the TracePrivately iOS app. Based on the Apple/Google (COVID-19) Exposure Framework.

Table of Contents

Objectives

Security

Admin

Government agents or helth professionals can view recent submissions and confirm test results.

Screenshot of a list of submissions Screenshot of an individual submission

API

Request an authentication token (Tokens expire after 7 days):

$ curl -s -v -X POST -H "Accept: application/json" "http://localhost:3000/api/auth" | jq
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
{
  "status": "OK",
  "token": "wXxgbZ8ztwZS5woTgpsBzNwY",
  "expires_at": "2020-05-03T12:25:11Z"
}

Get a list of infected keys since a specific time (Limited to 21 days ago):

$ curl -s -v -X GET -H "Authorization: Bearer c6rxEAhRcWSh2y8WSF1bYwgA" -H "Accept: application/json" "http://localhost:3000/api/infected?since=2020-04-19T00:00:00Z" | jq
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
{
  "status": "OK",
  "date": "2020-04-28T10:26:29Z",
  "keys": [
    {
      "d": "RDgwNjlEM0EtMzU2OC00MzY4LTkzRjAtQTA4MzVFNkREQjI2XzEz",
      "r": 1,
      "l": 20
    },
  ],
  "deleted_keys": [
    {
      "d": "RDgwNjlEM0EtMzU2OC00MzY4LTkzRjAtQTA4MzVFNkREQjI2XzEy",
      "r": 2,
      "l": 20
    }
  ]
}

Submit infected keys:

$ curl -s -v -X POST -H "Authorization: Bearer wXxgbZ8ztwZS5woTgpsBzNwY" "Accept: application/json" -H "Content-Type: application/json" -d '{"keys":[{"d":"RDgwNjlEM0EtMzU2OC00MzY4LTkzRjAtQTA4MzVFNkREQjI2XzI=","r":1234,"l":20}]}' "http://localhost:3000/api/submit" | jq
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
{
  "status": "OK",
  "identifier": "21532f3e-461d-4cb5-9304-602936757bc7"
}

Developing or Hosting the Key Server

System Dependencies

For running or developing the app:

For developing the app:

Developing on your computer

The setup script will install the app's dependencies and prepare the database.

$ ./bin/setup

Run the test suite to see if everything is working correctly.

$ ./bin/rails test
$ ./bin/rails test:system

Start the server on port 3000 and begin receiving requests:

$ ./bin/rails server --port 3000

Destroy all expired submissions and expired access grants:

$ ./bin/rails db:prune

License

This software is available as open source under the terms of the MIT License. See LICENSE.