» pip install Flask-Security-Too
The Right Gatekeepers: How to secure your Flask app with Flask-Security
python - Flask-Login vs Flask-Security for Production Environment - Stack Overflow
python - Flask Security Permissions of Roles - Stack Overflow
Flask Role Based Access in 2024?
This week I wrote a new tutorial for the publication, "Python in Plain English" on how to secure your Flask Admin dashboard with Flask-Security.
There were quite a few steps involved in making Flask Admin and Flask Security work well together. This included having to downgrade to Flask-Security-Too version 4.1.5. Let me know in the comments what you think. I am also using Flask-Admin 1.6.1
If you are not a Medium member you can click the "friend link" at the top of the tutorial: https://python.plainenglish.io/the-right-gatekeepers-secure-your-python-flask-app-with-flask-security-part-2-2-2cf8a7f1e667
Flask-Security is now deprecated, so I wouldn't recommend using it in production. There is a fork of it called Flask Security Too but it doesn't seem very widely followed.
To be honest even when it was maintained it wasn't my favourite as I think it tried to do too much.
Flask-Login on the other hand is a solid library. It is very "flasky" in the sense that it is low level and deals with the really annoying stuff (creating a session, persisting it with cookies, delivering a current_user, putting certain routes behind a login_required decorator) and then letting you design your own flow and pull in the libraries you want.
For instance if you want social login or OAuth token storage then Flask-Dance, which integrates nicely with Flask-Login and is actively maintained, smashes Flask-Social which integrates with Flask-Security.
There is also Flask-User, which gets good reviews but last commit was in 2019, which is a little scary.
Flask-Security-Too, while it can be complex if you try to use all of its features, proves to actually be pretty easy to set up production-ready applications. It is actively maintained. I have a few working projects in production using this library (v4.x.x). Not too long ago, there has been a v5.x.x release as well.
You should definitely check that out.
- Flask-Security-Too: https://flask-security-too.readthedocs.io/
- My Example Application: https://github.com/hrishikeshrt/flask-bootstrap-anywhere