Closed code-angels closed 4 years ago
Fixed this by using this in the plugin:
req.egContext.authUser = verifyToken(jwt);
And defining a request-transformer:
- request-transformer:
- action:
body:
add:
authUser: req.egContext.authUser
I'm quite struggling with the following problem.
I have created a small plugin because I want custom jwt middleware verification on certain endpoints.
The policy works as expected, but for some reason I'm not able to set a new property 'user' object on the req object in a way that it is propagated to the actual service endpoint. I need this user object to perform certain tasks in my service endpoints.
Policy:
This works, and it correctly logs the req.user object here.
Added to the pipeline:
But as mentioned, the req.user object is not propagated to the actual service endpoint.
Perhaps what I try to achieve is possible through the standard jwt plugin, but it isn't all that clear how this simple case may be achieved. Any help with this?