I would suggest using the flask-login extension, it makes session management really easy to add to your flask application, and provides a nice documentation which covers in details every aspect of the extension.
python - Flask user authentication - Stack Overflow
Understanding Flask authentication, authorisation, session management
What is the best authentication system for production flask apps?
[AF] Simple way to implement user authentication?
Videos
I would suggest using the flask-login extension, it makes session management really easy to add to your flask application, and provides a nice documentation which covers in details every aspect of the extension.
I don't think that flask has any authentication built-in, only support for tracking sessions.
Here are some snippets for basic HTTP authentication and authentication with some third-party providers. Otherwise you will need to roll your own or use a framework that has this baked in (like Django)
Here is a discussion thread on this topic with a useful link
What I do?
A User model, most important part of my application usually connected to dozens of other models.
User enters their unique username and password in a form on /register endpoint and submits.
The information submitted by user is recieved at backend.
I hash the password using bcrypt and save it in password_hash field.
For /login I match user password hash with the saved hash.
I use Flask-Login which is a "user session management" library according to documentation.
I add @login_required to routes I need user to be authenticated.
My burning questions
-
What is authentication part of this flow and what is authorisation part?
-
What is this "flow" called? Traditional...?
-
What is Flask-login doing exactly? What happens if I don't use it?
-
I am handling login/signup part almost manually, I'd like to do session part too, how does that work?
-
My "API endpoints" are where I recieve json data and return jsonify data and it works fine with the same setup. So why do "APIs need different way to auth/auth"? Is this because "browser is sending the cookie containing session info"?
-
What is the right way to do auth/auth in an application which will be accessed by browsers (both template rendered views and endpoints) & by raw api clients (say PostMan)
-
What is OAuth? 1/2?
-
Is OAuth only required when I need Google/Github/etc. login for my application? Or can it be used in "my flow"? Or should it be?
-
IdP (Identity Providers...?)
-
IAM (Identity Access Management?)
p.s. sry for this large post, u r not supposed to answer everything. any help appreciated, thanks