flask-rbac
flask-rbac copied to clipboard
Unable to use @rbac.exempt with Blueprints
PR-29 Added the ability to specify endpoints for the @rbac.allow and @rbac.deny to allow them to play nicely with blueprints
@rbac.exempt still uses the view_func.__name__
and hence, doesn't work with blueprints. For backwards compatibility, I suppose it might be useful to provide another exempt function that can take an endpoint parameter
If this is affecting any, the work around to inhert the RBAC and redefine the exempt decorator
class MRBAC(RBAC):
def exempt(self, endpoint=None):
def decorator(view_func):
self.acl.exempt(endpoint or view_func.__name__)
return view_func
return decorator
rbac = MRBAC()
@blueprint.route('/everyone/can/access')
@rbac.exempt(endpoint='blueprint.everyone_can_access')
def everyone_can_access():
return 'Hello~'
Same issue here, thanks for reporting daobeng & for workaround