Security

For user authentication security, we will use Flask's httpauth extension, written by Miguel Grinberg, as well as the password functions in Werkzeug. The httpauth extension should have been installed as part of the requirements.txt installation at the beginning of this chapter. The new file illustrating the security feature is named chapter9_9.py; we will start with a few more module imports:

...from werkzeug.security import generate_password_hash, check_password_hashfrom flask.ext.httpauth import HTTPBasicAuth...

We will create an HTTPBasicAuth object as well as the user database object. Note that, during the user creation process, we will pass the password value; however, we are only storing password_hash instead of the password ...

Get Mastering Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.