Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ukitgroup/koa-authentication-middleware

ukit-pro10MIT1.0.1

Koa-authentication-middleware

koa, koa2, nodejs, node, node10

readme

koa-authentication-middleware

Usage example

1) Сначала нужно cформировать подписанный токен

const sign = jwt.sign(
    {
        userId: 'some user id',
    },
    'secretKey',
);

И кладем в заголовок Authorization: Bearer ${sign}

2) Теперь осталось тодько обернуть роуты мидлаваром

import koaAuthenticationMiddleware from 'koa-authentication-middleware'

router.get('/route', koaAuthenticationMiddleware('secretKey'), async ctx => {
    console.log(ctx.state.userId);
});