This document provides guidance on setting up an IPManager Django development environment on a local workstation.
-
Python 3.12
-
Install
libxmlsec1. This is required for the SAML authentication using djangosaml2.On Mac, it is available via Homebrew:
brew install xmlsec1
On Debian or Ubuntu Linux, it is available via
apt:sudo apt-get install xmlsec1
-
Update the
/etc/hostsfile to add:127.0.0.1 ipmanager-local
-
Clone ipmanager-django from GitHub:
git clone git@github.com:umd-lib/ipmanager-django.git cd ipmanager-django -
Set up the Python virtual environment, and install the dependencies
python -m venv .venv --prompt "ipmanager-django-py$(cat .python-version)" source .venv/bin/activate pip install --upgrade pip pip install -e .
-
Retrieve the SAML Key and Cert information. The cert file can be accessed through Box. Alternatively, you can pull the key and cert from the Kubernetes cluster into files using the following commands:
# Key File kubectl -n test get secret ipmanager-common-env-secret -o jsonpath='{.data.SAML_SP_PRIVATE_KEY}' | base64 --decode > ipmanager-key.key # Certificate File kubectl -n test get secret ipmanager-common-env-secret -o jsonpath='{.data.SAML_SP_CERTIFICATE}' | base64 --decode > ipmanager-cert.crt
ℹ️ Note: These files can be placed in a directory outside the project, if desired - just change the location of the output file.
-
Copy the "env_example" file to ".env":
cp env_example .env
and update the following variables with the appropriate values:
- SAML_KEY_FILE - relative (or absolute) file path to the
ipmanager-key.keyfile - SAML_CERT_FILE - relative (or absolute) file path to the
ipmanager-cert.crtfile - SECRET_KEY - Either comment out (a random key will be automatically
generated), or populate with anything with sufficient randomness,
i.e.
uuidgen | shasum -a 256 | cut -c-64 - XMLSEC1_PATH - The full file path to the "xmlsec1" binary, (usually
findable by running
which xmlsec1)
- SAML_KEY_FILE - relative (or absolute) file path to the
-
Initialize the database:
./src/manage.py migrate
-
Run the application. The default port is 3001; this is also the port that is registered with DIT to allow SAML authentication to work from local:
./src/manage.py runserver
The application will be running at http://ipmanager-local:3001/
To change the port, provide an argument to
runserver, e.g.:./src/manage.py runserver 5555
To install test dependencies, install the test extra:
pip install -e '.[test]'This project uses pytest in conjunction with the pytest-django plugin to run its tests. To run the test suite:
pytestTo run with coverage information:
pytest --cov src --cov-report term-missing