The Cordet FW Editor provides an environment where users define various kinds of specification items for their applications. The specification information is stored in a database held on a server. The processing of the specification data is done by a back-end running on the server. The access to the editor data is through a browser on a client machine.
Release 1.0.0 of the editor has been in use for some time at P&P Software GmbH.
- Install Django
python3 -m pip install Django - Install Django-Crispy-Forms
pip3 install django-crispy-forms - Install cexprtk
pip3 install cexprtk - Set up a mySQL server
- If no database is available for import:
- Create database cordetfw
- In cordetfw_editor directory, run:
python3 manage.py createsuperuserand create theadminuser with superuser rights - Start the server on localhost with:
python3 manage.py runserver - Navigate to:
http://localhost:8000/editor/and selectadminto create the users, the projects, and the ValSets (make sure that each project has at least one ValSet calleddefault)
- If a database is available, import it
- Start the server on localhost with:
python3 manage.py runserver - Navigate to:
http://localhost:8000/editor/
- STATICFILES_DIRS in
settings.pycontains an absolute path! - For the customization of the auto-completion list (e.g. changing number of entries): see issue #6
The requirement.txt file contains the exact library versions.
- load
source path_to_venv/bin/activatee.g.source python-app-venv/bin/activate - save dependencies
pip3 freeze > requirements.txtin the project root
ssh <your host>cd <editor_directory>git pull origin- Import static resources and (if required) run the migration
source python-app-venv/bin/activatepython3 manage.py migratepython3 manage.py collectstaticdeactivate
sudo systemctl reload apache2.service
The CSS for the editor is created in an external tool and is tailored for the editor. The description of the creation and customization procedure for the CSS is still TBD.
Check python libraries verison and update to latest.
- ssh to server
cd <editor_directory>- load environment
source python-app-venv/bin/activate pip list --outdated- update listed packaged with
pip install -U PACKAGE_NAME - update
requirements.txtwithpip freeze > requirements.txt - add update
requirements.txtto git
load
requirements.txtwithpip install -r requirements.txt
Django provides a deployment checklist
Done
SECRET_KEYis loaded from configuration fileDEBUGis loaded from configuration file but should be disabledALLOWED_HOSTSset according to server ip/dnsCACHESnot relevant for us?DATABASEpassword is loaded from configuration fileEMAIL_BACKENDnot relevant for us?STATIC_ROOTandSTATIC_URLis setMEDIA_ROOTandMEDIA_URLno uploaded files- https enabled in apache2
CSRF_COOKIE_SECUREisTrueSESSION_COOKIE_SECUREisTrue- add logging to
/home/pnp/djangoLogging/info.login formatYYYY-MM-DDTHH:MM:SS+0000|level|modul|message - run
sudo mysql_secure_installation - add
bind-address=127.0.0.1in/etc/mysql/conf.d/mysql.cnfunder[mysql]restart withsudo /etc/init.d/mysql restart
To Do
- Performance optimization chapter in deployment checklist
- Error reporting per mail and customize error views not done
Additional list: Django Secrity Tips
- check use a secure django version
- check throttle user authentications
- check protect source code
- check use raw queries and custom SQL with caution
- done use HTTPS
- not done headers (more privacy than security?)
- done cookies only over https
- check user upload (do we have?)
- check security risks of dependencies
Security in the Django Application
- check SQL injection
- check if logged CRLF injection
- check but no prio timing attack
- check but no prio clickjacking attack
- check cross-site scripting
- check CSRF
- check HTTP strict transport security
10 tips for making the Dajngo Admin more secure
- done use SSL
- do change Admin URL
- do use
django-admin-honeypot - check require stronger password
- maybe use two-factor authentication
- check use latest version of Django
- done never run
DEBUGin production - check remember your environment
- check check for errors with
python manage.py check --deploy