Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does something like CanCan (authorization library) exist for flask and python

I love @rbates CanCan ruby library for authorization. Was wondering if anything similar existed for python / flask ?

I guess there are three main requirements:

  1. simple declarative way of defining abilities (here is how CanCan does it)
  2. decorator for flask routes
  3. fine-grained way for checking abilities in other parts of the code. i.e. if current_user.can('post::edit') or something

Or, what is the one obvious way to do it? (PEP-20)


Current Options:

  • Flask Simple Authorization (leaning towards something like this for now.)
  • Flask Principal (They all feel a bit heavy weight to me)
like image 423
Jonathan Avatar asked Jun 11 '13 14:06

Jonathan


2 Answers

One year later, I ended up writing one:

https://github.com/jtushman/bouncer

https://github.com/jtushman/flask-bouncer

like image 156
Jonathan Avatar answered Nov 17 '22 09:11

Jonathan


I recommend you keep an eye on Cork. Currently it's an authentication and authorization framework just for Bottle, but on the roadmap is Flask support. Pretty awesome.

like image 1
philadams Avatar answered Nov 17 '22 08:11

philadams