2022-09-12 20:24:21 +00:00
|
|
|
Flask-based web interface for user token administration of our hackerspace's door lock.
|
2022-01-29 22:45:31 +00:00
|
|
|
|
2022-02-04 22:08:52 +00:00
|
|
|
## Installation
|
|
|
|
Clone the repo
|
|
|
|
```shell
|
|
|
|
git clone <path_to_repo>
|
|
|
|
```
|
|
|
|
Install using pip
|
|
|
|
```shell
|
|
|
|
pip install .
|
|
|
|
```
|
|
|
|
|
|
|
|
## Running the app
|
|
|
|
```shell
|
|
|
|
export FLASK_APP=imaginaerraum_door_admin
|
|
|
|
flask run
|
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
You can set custom configuration options by defining an environment variable
|
|
|
|
``APPLICATION_SETTINGS`` pointing to a file with configuration options.
|
|
|
|
|
|
|
|
For example, consider the following configuration file ``app_config.py``:
|
|
|
|
```
|
|
|
|
# door app configuration
|
|
|
|
SECRET_KEY = 'mysupersecretkey'
|
|
|
|
SECURITY_PASSWORD_SALT = 'saltycaramel'
|
|
|
|
|
|
|
|
TESTING = False
|
|
|
|
DEBUG = False
|
|
|
|
|
|
|
|
TOKEN_FILE = 'door_tokens.txt'
|
|
|
|
ADMIN_FILE = 'admins.txt'
|
|
|
|
|
|
|
|
NFC_SOCKET = "/tmp/nfc.sock"
|
|
|
|
NFC_LOG = "nfc.log"
|
|
|
|
```
|
|
|
|
To instruct the flask app to use this configuration, use the following commands:
|
|
|
|
```shell
|
|
|
|
export APPLICATION_SETTINGS=app_config.py
|
|
|
|
flask run
|
|
|
|
```
|
|
|
|
|
|
|
|
Below, you can find a list of configuration options.
|
|
|
|
|
|
|
|
### Flask app configuration
|
|
|
|
You can override common Flask configuration variables. In particular, you
|
|
|
|
definitely should set custom values for the ``SECRET_KEY`` and
|
|
|
|
``SECURITY_PASSWORD_SALT``.
|
|
|
|
|
|
|
|
### Token file
|
2022-09-12 20:24:21 +00:00
|
|
|
The token file is an ASCII file which lists the IDs of RFID tokens that can be
|
2022-02-04 22:08:52 +00:00
|
|
|
used to unlock the door. You can specify the path to the token file using the
|
|
|
|
``TOKEN_FILE`` variable in the configuration file.
|
|
|
|
Here's an example of a token file (lines starting with ``#`` represent inactive
|
|
|
|
tokens):
|
|
|
|
```
|
|
|
|
# token | name | organization | email | valid_thru
|
|
|
|
#042979fa186280||||
|
|
|
|
04487cfa176280|Frodo|Hobbits|frodo@shire.me|
|
|
|
|
043a85fa1a6280|Gandalf|Wizards|gandalf@middleearth.me|
|
|
|
|
#04206e2aef6880|Boromir|Humans|boromir@gondor.me|
|
|
|
|
```
|
|
|
|
|
|
|
|
### Admin file
|
|
|
|
``ADMIN_FILE`` -> file to create new super admins
|
|
|
|
|
|
|
|
### User database
|
|
|
|
|
|
|
|
### NFC files
|
|
|
|
``NFC_SOCKET = "/tmp/nfc.sock"`` -> unix socket to interact with the door
|
|
|
|
``NFC_LOG = "nfc.log"`` -> log file of door events
|
2022-01-29 22:45:31 +00:00
|
|
|
|
2022-02-04 22:08:52 +00:00
|
|
|
## Development
|
2022-01-29 22:45:31 +00:00
|
|
|
```shell
|
|
|
|
cd tests
|
|
|
|
export APPLICATION_SETTINGS=/home/simon/imaginaerraum/door-lock/webinterface/tests/debug_app_config.py
|
|
|
|
pytest --cov=../imaginaerraum_door_admin --cov-report=html --cov-report=term
|
|
|
|
```
|