A Harvester Control Center GUI with REST-API written in Django.
- Django: The web framework for perfectionists with deadlines (Django builds better web apps with less code).
- DRF: A powerful and flexible toolkit for building Web APIs
- Python3: Python is a highly flexible and versatile programming language supporting a vast of use cases like web dev, GUI dev, scientific and numeric, software dev and sys admin
- FontAwesome: Fontawesome Version 4.7
- Bootstrap: Bootstrap 4
- Basic Authentication via Username and Password
- Token Authentication via Auth.-Token (see below)
- OAuth will be implemented... what about FIDO2 eh?
If you wish to run your own build, first ensure you have python globally installed in your computer. If not, you can get python here.
Then, Git clone this repo to your PC
git clone https://...
After doing installation, confirm that you have installed virtualenv globally as well. If not, run this:
pip install virtualenv
Change into the cloned repo as such:
cd {{your_repo_path}}
Create and fire up your virtual environment:
virtualenv venv -p python3
source venv/bin/activate
Install the dependencies needed to run the app:
pip install -r requirements.txt
(optional) Make those migrations work
python manage.py makemigrations
python manage.py migrate
To use Django Testing Environment fire the following command in your Terminal
python manage.py test
First, create a super-user and then switch DEBUG mode on in settings.py
python manage.py createsuperuser
Fire up the server using this one simple command:
DEBUG=True python manage.py runserver
or
make runlocal
You can now access the service on your browser by using the following URLS. /docs for swagger api documentation. /v1 is the HCC API endpoint. /admin is the admin-webinterface provided by django.
A GUI is accessible on your browser by using
Get your USER_TOKEN via POST-request to Resource /v1/get-token/
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"username": "username", \
"password": "password" \
}' 'http://localhost:8000/v1/get-token/'
For instance getting all harvesters (/v1/harvesters/) via Token-Authentication:
curl -X GET --header 'Accept: application/json' --header 'X-CSRFToken: AJcweNkQirt51Z2lg0c94FujhSNYFiu5grZLR2N4D8r1X2wrUaUlK8EOieEStFR9' --header 'Authorization: Token [USER_TOKEN]' 'http://localhost:8000/v1/harvesters/'
A Docker Container for production with nginx as buildin reverse proxy. If you do have a SSL Configuration, please add the line "proxy_set_header X-Forwarded-Proto https;" in the nginx configuration found in folder nginx/nginx.conf.
To build the docker container...
make docker
There are seven ENV variables which could be used to configure production use. Feel free to set them as needed when starting the docker container. Set a console LOGLEVEL (default: INFO). GUI interaction will be logged to a file in log/debug.log
- name: "DEBUG" value: "False"
- name: "ALLOWED_HOSTS" value: "xxx.xxx.xxx.xxx,www.domainname.org"
- name: "USE_X_FORWARDED_HOST" value: "True"
- name: "SECURE_PROXY_SSL_HEADER" value: "https"
- name: "FORCE_SCRIPT_NAME" value: "/path/to/desired/endpoint"
- name: "SECRET_KEY" value: "a 50bit string"
- name: "LOGLEVEL" value: one of "[notset, debug, info, warning, error, critical]"
Now run that container.
make dockerrun