🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@outlinewiki/koa-passport

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@outlinewiki/koa-passport

Passport middleware for Koa

4.2.1
latest
Source
npm
Version published
Weekly downloads
2.7K
69.25%
Maintainers
1
Weekly downloads
 
Created
Source

koa-passport

Passport middleware for Koa

NPM Dependency Status Build Status

koa-passport versionkoa versionbranch
1.x1.xv1.x
2.x2.xv2.x
4.x2.xmaster

Migration to v3

  • change ctx.passport.* to ctx.state.* (e.g. ctx.passport.user to ctx.state.user)
  • don't call passport methods on ctx.req (e.g. use ctx.login instead of ctx.req.login)
  • update custom authentication callback arguments to err, user, info, status (e.g. passport.authenticate('local', function(err, user, info, status) { ... })(ctx, next))

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

Keywords

koa

FAQs

Package last updated on 18 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts