Managing user credentials
The most common procedure for protecting any application from attacks is to control access to the user’s sensitive details, such as their username and password. Direct use of saved raw user credentials for login validation will not protect the application from attacks unless the application derives passphrases from the passwords, saves them into the database, and applies them for user validation instead.
This topic will cover password hashing using Hashlib and Bcrypt, password encryption using symmetric cryptography, and utilizing the sqlalchemy_utils
module for the seamless and automatic encryption of sensitive data.
Encrypting user passwords
Generating a passphrase from the username and password of the user is the typical and easiest way to protect the application from attackers who want to crack down or hack a user account. In Flask, there are two ways to generate a passphrase from user credentials:
- The hashing process: A one-way...