A super light-weight alternative to Flask-User or Flask-Security that adds role requirements for views to Flask-Login.
Project description
Flask-Login-Role
A super light-weight alternative to Flask-User or Flask-Security that adds role requirements for views to Flask-Login.
Features
role_required
This decorator requires that a user be authenticated and have their role attribute set to one of the roles specified. If the current user is authenticated but does not have their role in the specified roles, the user is sent to the LoginManager.no_role
callback.
no_role
This method of LoginManager
requires that you provide a no_role_view
attribute to LoginManager
. no_role_view
can be provided where you provide a login_view
for unauthorized users.
Installation
pip install Flask-Login-Role@git+https://github.com/glyzinieh/flask-login-role
Usage
See examples/app.py for an example of proper set up.
User
model will need arole
attribute with the required permissions.from flask_login_role import no_role
, and add ano_role
method toLoginManager
- Give
LoginManager
ano_role_view
attribute that is a string that indicates which view function to redirect authorized but unprivileged users to. from flask_login_role import role_required
wherever routes are defined, and decorate privilleged routes.
Thanks
Thanks to @schwartz721 for creating the project from which we forked.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask_login_role-1.0.0.tar.gz
.
File metadata
- Download URL: flask_login_role-1.0.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9d8ced171c316f076f7428eeb1113c8aeaa2c2ea5e104234497e3e2e09b4e6b |
|
MD5 | a33733cb0f76a9926204755f5b9ac2ab |
|
BLAKE2b-256 | eaa8312bb330942be25a212c98ac44962cdd161b0465d0fa0fd05b430109c653 |
File details
Details for the file Flask_Login_Role-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: Flask_Login_Role-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d5fbb438adb5aa30dbf86ee2f839e7c4e39e816cf3341bd777a0ef83fdec2ee |
|
MD5 | 78147c5a32a93c0fccd66c9ff5f6fb26 |
|
BLAKE2b-256 | e0078c5ebb8ee887a331c3977947728d675fe4300417fe05822272eda3edcab3 |