# egg-passport-alipay

> alipay passport plugin for egg

Latest version **1.0.1** (published 2019-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-passport-alipay
pnpm add egg-passport-alipay
yarn add egg-passport-alipay
bun add egg-passport-alipay
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-06 |
| First published | 2019-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 5 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | chb.wang |
| Maintainers | chb.wang |
| Keywords | egg, eggPlugin, egg-plugin |

## Links

- npm: https://www.npmjs.com/package/egg-passport-alipay
- Repository: https://github.com/eggjs/egg-passport-alipay
- Homepage: https://github.com/eggjs/egg-passport-alipay#readme
- Issues: https://github.com/eggjs/egg/issues
- npm.io page: https://npm.io/package/egg-passport-alipay

## Dependencies (5)

- [moment](https://npm.io/package/moment.md) ^2.23.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [node-rsa](https://npm.io/package/node-rsa.md) ^1.0.2
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.4.24
- [passport-strategy](https://npm.io/package/passport-strategy.md) ^1.0.0

## Recent versions

- 1.0.1 (latest) — 2019-03-06
- 1.0.0 — 2019-01-11

## README

# egg-passport-alipay

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/egg-passport-alipay.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-passport-alipay
[travis-image]: https://img.shields.io/travis/eggjs/egg-passport-alipay.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs/egg-passport-alipay
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-passport-alipay.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs/egg-passport-alipay?branch=master
[david-image]: https://img.shields.io/david/eggjs/egg-passport-alipay.svg?style=flat-square
[david-url]: https://david-dm.org/eggjs/egg-passport-alipay
[snyk-image]: https://snyk.io/test/npm/egg-passport-alipay/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-passport-alipay
[download-image]: https://img.shields.io/npm/dm/egg-passport-alipay.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-passport-alipay

支付宝第三方登录
* 支持沙箱环境
* 支持登录成功跳转回之前页面

## 依赖说明

### 依赖的 egg 版本

egg-passport-alipay 版本 | egg 1.x
--- | ---
1.x | 😁
0.x | ❌

### 依赖的插件
* [egg-passport](https://www.npmjs.com/package/egg-passport)

## 开启插件

```js
// config/plugin.js
exports.passportAlipay = {
  enable: true,
  package: 'egg-passport-alipay',
};
```

## 使用方式
### 开启插件
```javascript
// config/plugin.js
module.exports.passport = {
  enable: true,
  package: 'egg-passport'
}

module.exports.passportAlipay = {
  enable: true,
  package: 'egg-passport-alipay'
}
```

### 配置
```javascript
// config/config.xx.js
exports.passportAlipay = {
  key: '',  // appId
  sceret: '',
  privateKey: '/config/alipay-private.pem', // 密钥
  publicKey: '/config/alipay-public.pem', // 公钥
  callbackURL: 'http://www.tianjin-air.com/passport/alipay/callback', // 回调地址
  sandbox: false  // 是否使用沙箱环境
}
```

### 挂载路由
```javascript
// app/router.js
router.get('/passport/alipay', {})
router.get('/passport/alipay/callback', app.passport.authenticate('alipay', { failureRedirect: '/member/login.html', successRedirect: '/' })
```

### 用户信息处理
```javascript
// app.js
app.passport.verify(async (ctx, user) => {
  // 调用第三方登录接口 或 保存到session
  return user
})
```

### 支持登录成功跳转回之前页面
在跳转第三方登录入口链接上添加`?done=url`即可

## 详细配置

请到 [config/config.default.js](config/config.default.js) 查看详细配置项说明。

## 单元测试

<!-- 描述如何在单元测试中使用此插件，例如 schedule 如何触发。无则省略。-->

## 提问交流

请到 [egg issues](https://github.com/eggjs/egg/issues) 异步交流。

## License

[MIT](LICENSE)

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