How would you implement user authentication in a Flask application?
Instruction: Discuss your approach to adding user authentication to a Flask application.
Context: This question assesses the candidate's ability to implement secure user authentication mechanisms within a Flask application.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Define the identity source and account lifecycle first. A local password system needs registration, credential verification, recovery and revocation; an external identity provider needs verified protocol responses and stable identity mapping. Do not treat a submitted username as proof of identity.
Flask-Login manages login-session state and provides tools such as login_required; it does not store users, verify passwords or implement all permissions. Load users by a stable ID and reject unavailable/inactive accounts according to the policy...