Skip to content

📮 Restful API for the Petition of the DDDC pilot project

License

Notifications You must be signed in to change notification settings

DECODEproject/dddc-petition-api

Repository files navigation


dddc-petition-api
DDDC Petition API

Restful API for the PETITIONS of the Digital Democracy and Data Commons pilot project
Build Status codecov Dyne.org



Petition API is part of the DDDC.

Digital Democracy and Data Commons is a pilot participatory process oriented to test a new technology to improve the digital democracy platform Decidim and to collectively imagine the data politics of the future.

This pilot takes place in the context of the European project DECODE (Decentralized Citizen Owned Data Ecosystem) that aims to construct legal, technological, and socioeconomic tools that allow citizens to take back control over their data and technological sovereignty.

Our effort is that of improving people's awareness of how their data is processed by algorithms, as well facilitate the work of developers to create along privacy by design principles using algorithms that can be deployed in any situation without any change.

🚩 Table of Contents (click to expand)

🚀 Getting started

This requires docker to be installed

git clone --recursive https://github.com/DECODEproject/dddc-petition-api.git
cd dddc-petition-api
./start.sh

This will clone the project and all submodules of the project (--recursive is important) then by lunching the start.sh will create a docker container with all the dependencies correctly configured.

Head your browser to:

SWAGGER UI: http://0.0.0.0/docs/

API: http://0.0.0.0/


💾 Install

To locally run you need to run over a the API project over an ASGI server like uvicorn.

Assuming you are already cloned the project as described on Getting started with the submodules and already cd into your project directory dddc-petition-api you need the following steps

  1. create a virtualenv
  2. activate the virtualenv
  3. upgrade the pip
  4. install dependencies
  5. install the ASGI server
  6. run locally the API
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -e .
pip install uvicorn
uvicorn app.main:api --log-level debug --reload

🎮 Usage

This API server is meant for the Petition of the DDDC Project part of the DECODE project.


🐳 Docker

docker build -t dddc-petition-api .
docker run --rm -p 80:80 -e APP_MODULE="app.main:api" -e LOG_LEVEL="debug" -it dddc-petition-api

All the options are documented on here


🐝 API

All the parameters and format of the input are documented on the swagger, below you'll find a quick description of each endpoint

/

Hello world endpoint


🔧 Configuration

export DEBUG=true
export ROOT_SRC=${HOME}/src/dddc-petition-api

export DB_URL=sqlite:///${ROOT_SRC}/db.sqlite3

export JWT_ALGORITHM=HS256
export JWT_TOKEN_SUBJECT=access
export JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
export JWT_USERNAME=***
export JWT_PASSWORD=***
export JWT_RANDOM_SECRET=***

export CONTRACTS_DIR=${ROOT_SRC}/app/contracts/src/

export CREDENTIAL_ISSUER_USERNAME=***
export CREDENTIAL_ISSUER_PASSWORD=***
export CREDENTIAL_ISSUER_CREDENTIALS_DIR=${ROOT_SRC}/app/credentials/

export PETITION_CONTROL_TOKEN=***

Credentials folder

The credential folder contains credential previously created from the credential issuer and are store in file per sha256(credential_issuer_id) and the following three things are stored:

  • the credential object (output of 06-CITIZEN-aggregate-credential-signature.zencode) in form of filename HEX
  • the verifier keys of the credential issuer (04-CREDENTIAL_ISSUER-publish-verifier.zencode) HEX.verify
  • the private petition-api keys (01-CITIZEN-credential-keygen.zencode) HEX.keys

Eg. if the CREDENTIAL_ISSUER_CREDENTIALS_DIR=${ROOT_SRC}/app/credentials/ and the credential_issuer_uid='issuer_identifier' like https://petitions.decodeproject.eu/uid then the folder /app/credentials contains the following files:

3b2332e905bd662448d7114d0626421b82deb33fcf3bafe3c284bdfb9f58e2c6
3b2332e905bd662448d7114d0626421b82deb33fcf3bafe3c284bdfb9f58e2c6.keys
3b2332e905bd662448d7114d0626421b82deb33fcf3bafe3c284bdfb9f58e2c6.verify

📋 Testing

python3 setup.py test

🐛 Troubleshooting & debugging

To run the petition-api in debug mode, please run it in local and activate --debug when you launch the ASGI uvicorn server.

Set the LOG_LEVEL="debug" ENVIRONMENT VARIABLE that is used by uvicorn and starlette.


😍 Acknowledgements

Copyright ©️ 2019 by Dyne.org foundation, Amsterdam

Designed, written and maintained by Puria Nafisi Azizi Dyne.org.

With design contributions by Oleguer 'Ula' Sagarra dribia.com.

Special thanks to Denis 'Jaromil' Roio and Andrea D'Intino for their expert reviews.

Project funded by the European Commission

This project is receiving funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement nr. 732546 (DECODE).


🌐 Links

https://decodeproject.eu/

https://dyne.org/

https://zenroom.dyne.org/

https://dddc.decodeproject.eu/


👥 Contributing

Please first take a look at the Dyne.org - Contributor License Agreement then

  1. 🔀 FORK IT
  2. Create your feature branch git checkout -b feature/branch
  3. Commit your changes git commit -am 'Add some fooBar'
  4. Push to the branch git push origin feature/branch
  5. Create a new Pull Request
  6. 🙏 Thank you

💼 License

DDDC Petition API
Copyright (c) 2019 Dyne.org foundation, Amsterdam

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

About

📮 Restful API for the Petition of the DDDC pilot project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published