I need to authorize user based on some rols, so I need to:
class Things:
@falcon.before(myfunc, 'can_delete_tag')
@on_get(req, resp):
...
but it seems impossible... Any ideas?
I need to authorize user based on some rols, so I need to:
class Things:
@falcon.before(myfunc, 'can_delete_tag')
@on_get(req, resp):
...
but it seems impossible... Any ideas?
Falcon 1.3 seems to have the same restriction! Heres a work-around
import falcon
class HasPermission(object):
def __init__(self, role_name):
self.role_name = role_name
def validate_has_role(self, req, resp, resource, params):
raise falcon.HTTPBadRequest('Bad request')
and to use it.....
class Things:
@Authorize('can_delete_tag')
@on_get(req, resp):
...
write_access = HasPermission("WRITE").validate_has_role
read_access = HasPermission("READ").validate_has_role
Using internal falcon hooks is impossible unless we patch the functionality of falcon. Because hooks in falcon do not accept any parameters at all. But a standard decorator can do that:
and now we can use it: