JSON Web Tokens (JWT) with Restify
Published in
3 min readJun 18, 2017
This is a very simple example of signing and verifying JSON Web Tokens using Restify. If you’d like more information on either subject, check out the following links:
Getting Started
First, we’ll need to install a few dependencies
$ npm i --save restify restify-jwt-community jsonwebtoken
restify
will act as our api server (developed by Netflix)retify-jwt-community
is a middleware we'll use to validate json web tokensjsonwebtoken
is a library we'll use to create and sign json web tokens
As a sidenote: we could just as easily accomplish this without the use of extra middleware. However, restify-jwt-community
(forked from auth0/express-jwt
), provides us with a simple interface and drops a req.user
property for quick reference.
Second, we’ll start with a very basic restify server: