Flask user authentication

PythonAuthenticationMongodbFlask

Python Problem Overview


I have an application that will use flask and mongodb; I will probably host it on rackspace.

I need to understand how flask authenticating works. I have not found much information on the subject. Is there a complete tutorial on how to roll your own solution? If not, I certainly would like to hear some thoughts on how you would approach it for a a flask app.

Big PS:

I just thought about it. I also need to open a real API. A part of that API will be used for AJAX on the front end. How do i secure that part of the app?

Can anyone explain API auth requests?

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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

Solution 3 - Python

Flask-Login doesn't, technically, do authentication - it does session management, leaving the (tricky to securely implement) authentication details to you. Something like Flask-Security actually implements both session management and authentication (also nice-to-haves like password recovery/reset and the like), at the cost of having to have explicit support for your database.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpocorschiView Question on Stackoverflow
Solution 1 - PythonmdeousView Answer on Stackoverflow
Solution 2 - PythonrupelloView Answer on Stackoverflow
Solution 3 - PythonpjzView Answer on Stackoverflow