Juan Noriega
Juan Noriega

Reputation: 11

Flask Restless Preprocessors: GET_MANY doesn't works (auth REST API with Flask-Security)

Documentation is ambiguous, sometimes GET_MANY and other GET_COLLECTION are used. I need to make a preprocessor to authorize. GET_SINGLE does work (return 401: forbiden), but GET_MANY or GET_COLLECTION does not (return 200: ok).

@
auth_token_required@ roles_accepted('admin', 'supervisor')
def auth_func( * args, * * kw):
  print('@Juan: calling auth_func...')
pass

@ auth_token_required@ roles_accepted('adminxxx', 'supervisor')
def get_many(search_params = None, * * kw):
  print('@Juan: calling get_many...')
pass
preprocessors = {
  'GET_SINGLE': [auth_func],
  'GET_MANY': [get_many]
}
api_manager = APIManager(app, flask_sqlalchemy_db = db)
api_manager.create_api(Person,
  methods = ['GET', 'POST', 'DELETE', 'PUT'],
  preprocessors = preprocessors)

Upvotes: 1

Views: 181

Answers (0)

Related Questions