A "reference" example application for using the Bandwidth MFA Two-Factor Authentication Service Developers should follow this guide for configuring this example application to run, then use this reference application as a guide for either building a new application or modifying an existing application to leverage Bandwidth MFA for enhanced user security.
- Tested on Python 3.7
- Well organized directories with lots of comments
- app
- commands
- models
- static
- templates
- views
- tests
- app
- Includes test framework (
py.test
andtox
) - Includes database migration framework (
alembic
) - Sends error emails to admins for unhandled exceptions, but only if you have configured SMTP. Please see "Configuring SMTP" below.
We assume that you have git
and venv
virtual environment manager installed.
# Clone the code repository into ~/my_code/mfa-python-example-app
mkdir -p ~/my_code
cd ~/my_code
git clone https://bandwidth.com/mfa-python-example-app.git mfa-python-example-app
# Create the 'mfa-python-example-app' virtual environment
cd mfa-python-example-app
python3 -m venv .venv
source .venv/bin/activate
# Install the required Python packages
pip install -r requirements.txt
# Create DB tables and populate the roles and users tables
python manage.py init_db
Find the "Customer-specific configuration" section near the top of app/views/main_views.py and set your values for:
base64_encoded_username_and_password
account_id
messaging_application_id
from_phone_num
to_phone_num
# Start the Flask development web server
python manage.py runserver
Point your web browser to http://localhost:5000 (or http://127.0.0.1:5000 if you prefer)
You can make use of the following users:
- User with email address
member@example.com
and passwordPassword1
. - User with email address
admin@example.com
and passwordPassword1
.
# Start the Flask development web server
py.test tests/
If you make changes in the Models and run into DB schema issues, delete the sqlite DB file app.sqlite
.
Edit the local_settings.py
file.
Specifically set all the MAIL_... settings to match your SMTP settings
Note that Google's SMTP server requires the configuration of "less secure apps". See https://support.google.com/accounts/answer/6010255?hl=en
Note that Yahoo's SMTP server requires the configuration of "Allow apps that use less secure sign in". See https://help.yahoo.com/kb/SLN27791.html
- FlaskDash is a starter app for Flask with Flask-User and CoreUI (A Bootstrap Admin Template).
We appreciate the following Flask extensions:
Flask-User-starter-app was used as a starting point for this code repository.