# koa-passport

> Passport middleware for Koa

Latest version **6.0.0** (published 2023-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-passport
pnpm add koa-passport
yarn add koa-passport
bun add koa-passport
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2023-02-06 |
| First published | 2014-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/koa-passport) |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 1 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 771 |
| Author | Markus Ast |
| Maintainers | rkusa |
| Keywords | koa, passport, auth, authentication, authorization |

## Links

- npm: https://www.npmjs.com/package/koa-passport
- Repository: https://github.com/rkusa/koa-passport
- Issues: https://github.com/rkusa/koa-passport/issues
- npm.io page: https://npm.io/package/koa-passport

## Dependencies (1)

- [passport](https://npm.io/package/passport.md) ^0.6.0

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 6.0.0 (latest) — 2023-02-06
- 2.2.2 (next) — 2016-08-01
- 5.0.0 — 2022-07-19
- 4.1.4 — 2021-03-11
- 4.1.3 — 2019-04-18
- 4.1.2 — 2019-04-18
- 4.1.1 — 2018-09-07
- 4.1.0 — 2018-05-16
- 4.0.1 — 2017-10-04
- 4.0.0 — 2017-09-07
- 3.0.0 — 2017-02-28
- 1.4.0 — 2017-01-02
- 3.0.0-rc.3 — 2017-01-02
- 3.0.0-rc.2 — 2016-11-14
- 3.0.0-rc.1 — 2016-08-28
- … 26 more at https://npm.io/package/koa-passport/versions

## README

# koa-passport

[Passport](https://github.com/jaredhanson/passport) middleware for Koa

[![NPM][npm]](https://npmjs.org/package/koa-passport)

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

```js
// 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](https://github.com/rkusa/koa-passport-example)

Passport's values and methods are exposed as follows:

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

## License

  [MIT](LICENSE)

[npm]: http://img.shields.io/npm/v/koa-passport.svg
[dependencies]: http://img.shields.io/david/rkusa/koa-passport.svg
[travis]: https://travis-ci.org/rkusa/koa-passport.svg?branch=master

---
_Source: https://npm.io/package/koa-passport · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
