Authentication

In order to develop an authentication module, we are going to use the Flask-Login extension. The Flask-Login extension provides a user session management mechanism. It handles the common tasks for managing user sessions such as logging in, logging out, and remembering the user.

To integrate Flask-Login, you need to create the instance and define some default parameters, as described in the following code snippet:

from flask_login import LoginManager
app = Flask(__name__)
login_manager = LoginManager()
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.login'
login_manager.login_message_category = "info"
login_manager.init_app(app)

We are going to create an authentication module as an auth package. An auth package will have basic scaffolding, as shown here: