@ukitgroup/koa-authentication-middleware

1.0.1 • Public • Published

koa-authentication-middleware

Usage example

  1. Сначала нужно cформировать подписанный токен
const sign = jwt.sign(
	{
		userId: 'some user id',
	},
	'secretKey',
);

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

  1. Теперь осталось тодько обернуть роуты мидлаваром
import koaAuthenticationMiddleware from 'koa-authentication-middleware'

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

/@ukitgroup/koa-authentication-middleware/

    Package Sidebar

    Install

    npm i @ukitgroup/koa-authentication-middleware

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    20.2 kB

    Total Files

    14

    Last publish

    Collaborators

    • badpenguin
    • risok
    • l0gd0g
    • cheerlesscloud