linhe0x0 / koa-jwt

A jwt middleware for Koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

koa-jwt

A jwt middleware for Koa

Install

npm install @sqrtthree/koa-jwt

Usage

import * as Koa from 'koa'
import { jwtMiddleware } from '@sqrtthree/koa-jwt'

const app = new Koa()

app.use(
  jwtMiddleware({
    subject: 'identity_authentication',
  })
)

Options

subject: string

Target subject of jwt.

issuer: ?string

Target issuer of jwt.

secret: ?string | (tokenPayload) => Promise<string>

A string or function containing either the secret for HMAC algorithms.

stateName: ?string

Attribute name extended to ctx.state, the value is jwt payload. It will be jwtPayload by default.


sqrtthree.com  ·  GitHub @sqrthree  ·  Twitter @sqrtthree

About

A jwt middleware for Koa

License:MIT License


Languages

Language:JavaScript 68.6%Language:TypeScript 31.4%