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 specify payload post-processor #5

Closed dennismckinnon closed 9 years ago

dennismckinnon commented 9 years ago

I found I wanted to specially format the token payload and parse it properly when being submitted so I added the ability to pass a processPayload function which runs on decoded token payload. This is not a big change.

dennismckinnon commented 9 years ago

Bad form to complicate the PR but its such a simple fix I figured I would tack it on rather then make a second one.

Noticed that errors from jwt.decode were not caught. If token was corrupted and unable to be decoded this would result in a 500 internal error. Now it throws the more appropriate invalid credentials error.

amrav commented 9 years ago

@dennismckinnon This isn't what restify-jwt is intended to do. See #2. Your use case is implemented as custom middleware after restify-jwt.