-
-
Notifications
You must be signed in to change notification settings - Fork 247
Closed
Description
Hello, this is more a question than an issue.
I've added @jwt_required() on several routes
@routes.route('/devices', methods=['GET'])
@jwt_required()
def get_devices(args):
...
but I need to have a method that extracts, for each request, the user data from the JWT so it can verify if the user is authorized for the request. I though about adding a @jwt.user_lookup_loader in a @before_request method, something like the following:
@routes.before_request
@jwt.user_lookup_loader
def user_lookup_callback(_jwt_header, jwt_data):
email = jwt_data["sub"]
user = Database.find_one("accounts", {"username": email})
return user
but this is not working as expected. I think I'm missing something here.
Can a decorator be added to trigger some kind of authorization function before each @jwt_required() decorated routes ?
Metadata
Metadata
Assignees
Labels
No labels