Questions tagged [flask-principal]

23 questions
29
votes
1 answer

Using Flask-Security Roles with Flask-JWT REST API

I am building a Flask-based REST API and using Flask-JWT to handle JWT auth. I also want to use the built in roles management with Flask-Security. However, Flask-Security's @roles_required() decorator assumes I am showing a Flask view when it…
chrcoe
  • 412
  • 4
  • 13
11
votes
2 answers

Flask-auth, Principal and Flask Security

Can anyone tell if there's a fundamental difference between these 3 extensions or do they all do similar things? I've been reading the docs and there seems to be quite a lot of crossover. I'm guessing some just offer more features. I'm wanting to…
bobwal
  • 522
  • 6
  • 19
9
votes
1 answer

Flask-Principal Best Practice of Handling PermissionDenied Exception

I am new in writing flask and currently use flask-principal as my authorization mechanism. When a user tries to access a url without the required permission, flask-principal raises a PermissionDenied Exception. It causes my system to throw a 500…
Theon Lin
  • 330
  • 3
  • 8
9
votes
2 answers

Flask Login and Principal - current_user is Anonymous even though I'm logged in

I'm using Flask Login and Principal for identity and role management. My needs are described straight out of the docs. My code is here: @identity_loaded.connect_via(app) def on_identity_loaded(sender, identity): # Set the identity user object …
fansonly
  • 1,150
  • 4
  • 14
  • 29
7
votes
4 answers

Flask Principal granular resource on demand

I've been looking at this post: http://pythonhosted.org/Flask-Principal/#granular-resource-protection Now while there is nothing wrong with how it is currently working I can't see that it is very usable since at the time of login all posts are read…
Asken
  • 7,679
  • 10
  • 45
  • 77
6
votes
1 answer

Combining RoleNeed's with Flask Principal

I'm trying to create a permission that requires that the user has role A or role B. According to Python Flask Principal documentation, the following line creates a permission that requires the user has roleA AND roleB. combined_permission =…
Derek
  • 3,295
  • 3
  • 24
  • 31
6
votes
1 answer

Flask-Principal, Flask-Login, remember_me and identity_loaded

I work on a Flask app with Flask-Login and Flask-Principal and everything works fine so far except the remember me function of Flask-Login. Actually the remember me function works on the Flask-Login side, but the idenity_loaded function of…
Bouni
  • 133
  • 10
6
votes
3 answers

Unit-testing a flask-principal application

All, I'm writing a flask application that depends on flask-principal for managing user roles. I'd like to write some simple unit tests to check which views can be accessed by which user. An example of code is posted on pastebin to avoid cluttering…
Pierre GM
  • 19,809
  • 3
  • 56
  • 67
4
votes
1 answer

Flask-Admin Role based resource permissions

I am creating a Flask-Admin app that requires checking permissions to View, Edit & Delete certain rows in a table. i.e, I would like to: List only rows where the User ID matches the Owner ID of the row Let the user Create a row if they have a…
Rafael
  • 1,018
  • 1
  • 10
  • 18
3
votes
1 answer

Populate WTForm MultiCheckboxField with Flask-Principal Roles

I'm working on an edit user page for my flask app, and I can't seem to figure out how to render the user's current roles like I do other variables, such as email. Here's my models, form, and view: #Flask-Principal Role Model class Role(db.Model,…
Chockomonkey
  • 3,895
  • 7
  • 38
  • 55
3
votes
1 answer

Flask-Login & Flask-Principle authenticated user drops to flask_login.AnonymousUserMixin

I'm getting two problems My authenticated user constantly drops to flask_login.AnonymousUserMixin I get unexpected signalling using Flask-Login & Flask-Principal Trying to get /projects/10 URL which is protected…
DmitrySemenov
  • 9,204
  • 15
  • 76
  • 121
2
votes
1 answer

Flask-Principal require Triggering Exception before Flask-Login request_loader Called

For some time I've used Flask-Login to handle traditional username/password authentication requests and Flask-Principal to handle authorization checks against routes on subsequent requests. All has been well. I'm now trying to leverage Flask-Login's…
Rikaelus
  • 574
  • 1
  • 5
  • 15
2
votes
1 answer

Restricting one view on Flask-Admin?

I have a single file for a Flask application, views.py. Inside views.py, I have the setup for Flask-Admin and the corresponding sqlalchemy database here: db = SQLAlchemy(flaskapp) def build_db(): import random import…
1
vote
0 answers

Problem with app context and Flask Principal

I am having issues trying to make things work with the application factory pattern. I had a working Flask application with a bad code structure. Today I improved the structure and created a more suitable application factory. In order to access users…
nate-k
  • 191
  • 2
  • 10
1
vote
1 answer

How do you set the Flask-Principal identity in a unittest?

I'm testing a Flask application that uses Flask-Principal for role based permissions and also granular resource protection. I'm not sure how to handle setting the identity in post requests. I'm using the testing strategy outlined in this other…
bill__
  • 101
  • 1
  • 4
1
2