You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
👯 Split API into Guardian and Mediator modes (#74)
Guardian mode endpoints:
- /guardian/*
- /key
- /auxiliary/generate
- /election/generate
- /tally
- /decrypt-share
- /ping
Mediator mode endtpoints:
- /ballot/*
- /election/*
- /key/election/combine
- /tally
- /
- /append
- /decrypt
- /ping
The mode is determined on startup by the `API_MODE` environment variable, which can be set to either `guardian` or `mediator` (default).
The docker image accepts this environment variable if provided, and a docker-compose file has been added for easy local execution of the image in both guardian and mediator modes.
This is a python API that utilizes [`electionguard-python`](https://github.com/microsoft/electionguard-python) to perform ballot encryption, casting, spoiling, and tallying. This API is implemented using [FastAPI](https://fastapi.tiangolo.com/#interactive-api-docs).
7
8
8
-
This is a python API that utilizes [`electionguard-python`](https://github.com/microsoft/electionguard-python) to perform ballot encryption, casting, spoiling, and tallying. This API is implemented using [FastAPI](https://fastapi.tiangolo.com/#interactive-api-docs
9
-
).
9
+
## 👯♀️ Two APIs in One
10
10
11
+
The application can run in one of two modes:
11
12
12
-
## 💻 Requirements
13
+
-`guardian` mode runs features used by Guardians (key ceremony actions, partial tally decryption, etc.)
14
+
-`mediator` mode runs features used by Mediators (ballot encryption, casting, spoiling, etc.)
15
+
16
+
In practice, you will likely need to run at least one instance of each mode. We provide a single codebase and Docker image, but the mode can be set at runtime.
17
+
18
+
## 🐳 Running with Docker
19
+
20
+
If you run Docker and want to get started quickly, we provide a Dockerfile and docker-compose.yml.
21
+
22
+
Run both APIs at the same time:
23
+
24
+
```bash
25
+
make docker-run
26
+
```
27
+
28
+
Or run both APIs in development mode, with automatic reloading on file change:
29
+
30
+
```bash
31
+
make docker-dev
32
+
```
33
+
34
+
After either command, you will find the `mediator` API running at http://127.0.0.1:8000 and the `guardian` API at http://127.0.0.1:8001
35
+
36
+
## 🐍 Running with Python
37
+
38
+
### Requirements
13
39
14
40
_These requirements line up with [electionguard-python](https://github.com/microsoft/electionguard-python/blob/main/README.md#-requirements)._
15
41
16
42
-[Python 3.8](https://www.python.org/downloads/) is <ins>**required**</ins> to develop this API. If developer uses multiple versions of python, [pyenv](https://github.com/pyenv/pyenv) is suggested to assist version management.
17
43
-[GNU Make](https://www.gnu.org/software/make/manual/make.html) is used to simplify the commands and GitHub Actions. This approach is recommended to simplify the command line experience. This is built in for MacOS and Linux. For Windows, setup is simpler with [Chocolatey](https://chocolatey.org/install) and installing the provided [make package](https://chocolatey.org/packages/make). The other Windows option is [manually installing make](http://gnuwin32.sourceforge.net/packages/make.htm).
18
-
-[Gmpy2](https://gmpy2.readthedocs.io/en/latest/) is used for [Arbitrary-precision arithmetic](https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic) which
19
-
has its own [installation requirements (native C libraries)](https://gmpy2.readthedocs.io/en/latest/intro.html#installation) on Linux and MacOS. **⚠️ Note:**_This is not required for Windows but the python package must be installed with the precompiled libraries._
20
44
-[pipenv](https://github.com/pypa/pipenv) is used to configure the python environment. Installation instructions can be found [here](https://github.com/pypa/pipenv#installation).
21
45
22
-
##🚀 Quick Start
46
+
###Quick Start
23
47
24
48
Using [**make**](https://www.gnu.org/software/make/manual/make.html), installation and startup can be run with one command:
25
49
26
-
```
27
-
make
28
-
```
50
+
To set up the environment:
29
51
30
-
To start the api:
31
-
```
32
-
make start
52
+
```bash
53
+
make environment
33
54
```
34
55
35
-
## 🛠 Debugging
56
+
To start the api:
36
57
37
-
For local debugging with Visual Studio Code, choose the `Web API` option from the dropdown in the Run menu. Once the server is up, you can easily hit your breakpoints.
58
+
```bash
59
+
make start API_MODE=mediator
60
+
```
38
61
39
-
If the code fails to run, [make sure your Python interpreter is set](https://code.visualstudio.com/docs/python/environments) to use your pipenv environment.
62
+
OR
40
63
41
-
## 🐳 Docker
42
-
A DockerFile is available to quickly create and run a docker container.
64
+
```bash
65
+
make start API_MODE=guardian
66
+
```
43
67
68
+
### Debugging
44
69
45
-
Build docker container:
46
-
```
47
-
make docker-build
48
-
```
70
+
For local debugging with Visual Studio Code, choose the `Guardian Web API` or `Mediator Web API` options from the dropdown in the Run menu. Once the server is up, you can easily hit your breakpoints.
49
71
50
-
Run docker container:
51
-
```
52
-
make docker-run
53
-
```
72
+
If the code fails to run, [make sure your Python interpreter is set](https://code.visualstudio.com/docs/python/environments) to use your pipenv environment.
54
73
55
74
## 🧪 Testing
56
75
@@ -60,33 +79,35 @@ A Postman collection is available to test the API located in the `/tests` folder
60
79
61
80
**FastApi** defaultly has API documentation built in. The following is available after running:
62
81
63
-
-**[SwaggerUI](https://github.com/swagger-api/swagger-ui)** at [`http://127.0.0.1:8000/docs`](http://127.0.0.1:8000/docs)
82
+
-**[SwaggerUI](https://github.com/swagger-api/swagger-ui)** at [`http://127.0.0.1:8000/docs`](http://127.0.0.1:8000/docs) or [`http://127.0.0.1:8001/docs`](http://127.0.0.1:8001/docs), depending on the API mode
64
83
65
-
-**[ReDoc](https://github.com/Redocly/redoc)** at [`http://127.0.0.1:8000/redoc`](http://127.0.0.1:8000/redoc)
84
+
-**[ReDoc](https://github.com/Redocly/redoc)** at [`http://127.0.0.1:8000/redoc`](http://127.0.0.1:8000/redoc) or [`http://127.0.0.1:8001/redoc`](http://127.0.0.1:8001/redoc)
-[Read the Docs](https://electionguard-web-api.readthedocs.io/)
71
90
72
91
## 🗄 Archived
92
+
73
93
As of 06/15/2020, the previous C wrapped implementation was transitioned to the python version. ElectionGuard development has transitioned to the [ElectionGuard-Python](https://github.com/microsoft/electionguard-python) Repo. The old version is available using the `dotnet-api` tag.
74
94
75
95
## 🤝 Contributing
76
96
77
-
This project encourages community contributions for development, testing, documentation, code review, and performance analysis, etc. For more information on how to contribute, see [the contribution guidelines][Contributing]
97
+
This project encourages community contributions for development, testing, documentation, code review, and performance analysis, etc. For more information on how to contribute, see [the contribution guidelines][contributing]
78
98
79
99
### Code of Conduct
80
100
81
101
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
82
102
83
103
### Reporting Issues
84
104
85
-
Please report any bugs, feature requests, or enhancements using the [GitHub Issue Tracker](https://github.com/microsoft/electionguard-web-api/issues). Please do not report any security vulnerabilities using the Issue Tracker. Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). See the [Security Documentation][Security] for more information.
105
+
Please report any bugs, feature requests, or enhancements using the [GitHub Issue Tracker](https://github.com/microsoft/electionguard-web-api/issues). Please do not report any security vulnerabilities using the Issue Tracker. Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). See the [Security Documentation][security] for more information.
86
106
87
107
### Have Questions?
88
108
89
109
Electionguard would love for you to ask questions out in the open using GitHub Issues. If you really want to email the ElectionGuard team, reach out at [email protected].
90
110
91
111
## License
92
-
This repository is licensed under the [MIT License]
112
+
113
+
This repository is licensed under the [MIT License]
0 commit comments