- docker compose
- python >=3.12 (+ pyenv for easier version management)
start the local dev PgSQL database in docker
docker compose up databaseinstall pyenv for example, on MacOS, with brew:
# install some dependencies first
brew install openssl readline sqlite3 xz zlib
brew install pyenvinstall and use python version in pyenv
pyenv install 3.12.7
pyenv local 3.12.7install and set up a virtual environment and app dependencies
# create a virtual environment to keep this app's python libraries segregated from your system
python --version # 3.12.7
python -m venv .venv # creates a virtual environment in ./.venv
source ./.venv/bin/activate
(.venv) pip install -r passwordmanager/requirements.txtcopy the env-example to .env and make any changes you need, then run migrations and start the app
cp env-example .env
# ...
cd passwordmanager
python manage.py migrate && python manage.py runserverthen the app should be running on localhost:8000
to build and inject the frontend React app:
cd frontend
npm run buildvite will output the build assets and manifest into the django static directory. The directory is hardcoded in the vite config, and is the same one referenced in passwordmanager/settings.py as FRONTEND_MANIFEST_PATH
included is a Postman colelction JSON file that has tests for all the API endpoints. In order to simulate a authed/logged in session, there is a special endpoint that only runs when in development mode for getting a valid CSRF token and a sessionid to use in subsequent Postman requests. the sessionid corresponds to an auth session in Django once the login exchange happens.
Currently this repo is set up to use free gmail account as the SMTP provider. (See slack for credentials)
Vault routes are optinoally MFA protected. If the user is MFA enrolled, then MFA verification will be required to access hose endpoints, based on the MFARequiredIfOptedIn permissions class
Email-based MFA sends a verification code to the user's email address during login or enrollment.
Configure SMTP settings in your .env file (a free Gmail account is currently configured using an app password, see google app passwords)
Enrollment Flow:
- User requests email MFA enrollment via
/api/accounts/mfa/email/enroll/ - System sends verification email with time-limited code
- User enters code via
/api/accounts/mfa/email/verify/to complete enrollment - Email MFA is enabled for subsequent logins
Login Flow:
- User completes username/password authentication
- System sends MFA challenge code to user's email
- User enters code to complete authentication
TOTP MFA uses authenticator apps like Google Authenticator, Microsoft Authenticator, etc. to generate time-based codes. The code is based on a random secret that is stored in the user profile, and can be checked subsequently to ensure the user's auth app has the original code
Enrollment Flow:
- User initiates TOTP enrollment via
/api/accounts/mfa/totp/enroll/ - System generates a random secret key and buolds a QR code from it
- User can scan the QR code with their authenticator app or potentically use the random secret directly if their authenticator app uses it
- The app will then generate a code that canbe used to verify the original secret
- User enters the code via
/api/accounts/mfa/totp/verify/ - System validates code and enables TOTP for the account secret
Login Flow:
- User completes username/password authentication
- System prompts for current 6-digit TOTP code
- User enters code from their authenticator app
- System validates time-based code and grants access