Creating the Authentication Table
Explore building authentication tables with password hashing using Flask ORM. Understand how to securely store user information, avoid storing plain passwords, and set up database tables for user verification and API access control.
We'll cover the following...
Creating auth_orm.py
Implementing JWT in the database requires creating a new table that stores the usernames and enough information to verify the password, without actually storing the passwords since that’s an unnecessary security risk. The password hash is computed by applying the md5 function from the hashlib package to a concatenation of the user name, the password salt, and the password. How they are concatenated doesn’t matter so long as it’s done the same way each time. Here’s the entire Auth ORM class.
The _compute_hash method uses the username and salt values within the object to compute the password hash. The computed and stored hash values are then compared. This is ...