1.0.5 • Published 8 years ago
koa-jwtauth v1.0.5
koa-jwtauth
JSONWebtoken middleware for koa@2
This middleware watches for the authorization header and sets user data from jwttoken to ctx.state if the header exists.
Middleware can throws the Forbidden error and prevents next middleware execution or silently calls next middleware.
#Usage:
import jwtmiddleware from 'koa-jwtauth'
import {createHash} from 'crypto'
const securityToken = createHash('md5').update('Some salt').digest('hex');
//silent
app.use(jwtmiddleware(securityToken));
//throw 403 error
app.use(jwtmiddleware(securityToken, true));