koa-passport
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/koa-passport package

6.0.0 • Public • Published

koa-passport

Passport middleware for Koa

NPM

koa-passport version passport version koa version branch
6.x, 5.x 6.x, 5.x 2.x main
4.x 4.x 2.x v3.x
3.x, 2.x 2.x 2.x v2.x
1.x 1.x 1.x v1.x

Usage

// body parser
const bodyParser = require('koa-bodyparser')
app.use(bodyParser())

// Sessions
const session = require('koa-session')
app.keys = ['secret']
app.use(session({}, app))

const passport = require('koa-passport')
app.use(passport.initialize())
app.use(passport.session())

Example Application

Passport's values and methods are exposed as follows:

app.use(async ctx => {
  ctx.isAuthenticated()
  ctx.isUnauthenticated()
  await ctx.login()
  ctx.logout()
  ctx.state.user
})

License

MIT

Package Sidebar

Install

npm i koa-passport

Weekly Downloads

168,264

Version

6.0.0

License

MIT

Unpacked Size

17.1 kB

Total Files

7

Last publish

Collaborators

  • rkusa