koa-jwt-roles
Koa role middleware for use with koa-jwt.
Written for Koa 2 with Node 7.6+
For the Koa 1 version, use the latest 0.x version.
npm i -S koa-jwt-roles
This module checks against the context user decoded by koa-jwt.
Simple usage:
//... app, koa-jwt, koa-routerconst roles = ; // single checkrouter; // multiple checkrouter;
Router usage:
If you have a lot of routes, the previous example can become very tedious. The next example makes life a bit easier if an entire route prefix uses the same roles.
// this could be an admin router where you only want admin to access.... app koa-jwt koa-routerconst roles = ; router; router;