amrav / restify-jwt

restify middleware that validates a JsonWebToken (JWT) and sets the req.user with the attributes
Other
83 stars 30 forks source link

Add ability to enhance decoded data attached to request for e.g. loading data server-side #2

Closed jonathana closed 9 years ago

jonathana commented 9 years ago

I want to add the ability to send only a minimal number of values in the JWT token but still track more data server-side in a persistence store like e.g. redis. I have added the enhancedLoadCallback option to the middleware to enable the ability, after a JWT has been successfully decoded, to do additional operations based on the content of the JWT. Unit tests show a very simple example of "expiring" a session server-side, as well as enhancing one with fixed data in code.

amrav commented 9 years ago

@jonathana This isn't what restify-jwt is intended to do. Its only job is to pull out the JWT, decode it, and attach it to the request.

I think your use case is best implemented as custom middleware after restify-jwt.