正在显示
20 个修改的文件
包含
455 行增加
和
0 行删除
.autod.conf.js
0 → 100644
1 | +'use strict'; | |
2 | + | |
3 | +module.exports = { | |
4 | + write: true, | |
5 | + prefix: '^', | |
6 | + plugin: 'autod-egg', | |
7 | + test: [ | |
8 | + 'test', | |
9 | + 'benchmark', | |
10 | + ], | |
11 | + devdep: [ | |
12 | + 'egg', | |
13 | + 'egg-ci', | |
14 | + 'egg-bin', | |
15 | + 'autod', | |
16 | + 'autod-egg', | |
17 | + 'eslint', | |
18 | + 'eslint-config-egg', | |
19 | + ], | |
20 | + exclude: [ | |
21 | + './test/fixtures', | |
22 | + './docs', | |
23 | + './coverage', | |
24 | + ], | |
25 | +}; | ... | ... |
.eslintignore
0 → 100644
1 | +coverage | ... | ... |
.github/PULL_REQUEST_TEMPLATE.md
0 → 100644
1 | +<!-- | |
2 | +Thank you for your pull request. Please review below requirements. | |
3 | +Bug fixes and new features should include tests and possibly benchmarks. | |
4 | +Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md | |
5 | + | |
6 | +感谢您贡献代码。请确认下列 checklist 的完成情况。 | |
7 | +Bug 修复和新功能必须包含测试,必要时请附上性能测试。 | |
8 | +Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md | |
9 | +--> | |
10 | + | |
11 | +##### Checklist | |
12 | +<!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> | |
13 | + | |
14 | +- [ ] `npm test` passes | |
15 | +- [ ] tests and/or benchmarks are included | |
16 | +- [ ] documentation is changed or added | |
17 | +- [ ] commit message follows commit guidelines | |
18 | + | |
19 | +##### Affected core subsystem(s) | |
20 | +<!-- Provide affected core subsystem(s). --> | |
21 | + | |
22 | + | |
23 | +##### Description of change | |
24 | +<!-- Provide a description of the change below this comment. --> | ... | ... |
.github/workflows/nodejs.yml
0 → 100644
1 | +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
3 | + | |
4 | +name: Node.js CI | |
5 | + | |
6 | +on: | |
7 | + push: | |
8 | + branches: | |
9 | + - main | |
10 | + - master | |
11 | + pull_request: | |
12 | + branches: | |
13 | + - main | |
14 | + - master | |
15 | + schedule: | |
16 | + - cron: '0 2 * * *' | |
17 | + | |
18 | +jobs: | |
19 | + build: | |
20 | + runs-on: ${{ matrix.os }} | |
21 | + | |
22 | + strategy: | |
23 | + fail-fast: false | |
24 | + matrix: | |
25 | + node-version: [8, 10] | |
26 | + os: [ubuntu-latest, windows-latest, macos-latest] | |
27 | + | |
28 | + steps: | |
29 | + - name: Checkout Git Source | |
30 | + uses: actions/checkout@v2 | |
31 | + | |
32 | + - name: Use Node.js ${{ matrix.node-version }} | |
33 | + uses: actions/setup-node@v1 | |
34 | + with: | |
35 | + node-version: ${{ matrix.node-version }} | |
36 | + | |
37 | + - name: Install Dependencies | |
38 | + run: npm i -g npminstall && npminstall | |
39 | + | |
40 | + - name: Continuous Integration | |
41 | + run: npm run ci | |
42 | + | |
43 | + - name: Code Coverage | |
44 | + uses: codecov/codecov-action@v1 | |
45 | + with: | |
46 | + token: ${{ secrets.CODECOV_TOKEN }} | ... | ... |
.gitignore
0 → 100644
.travis.yml
0 → 100644
LICENSE
0 → 100644
1 | +The MIT License (MIT) | |
2 | + | |
3 | +Copyright (c) 2019-present Alibaba Group Holding Limited and other contributors. | |
4 | + | |
5 | +Permission is hereby granted, free of charge, to any person obtaining a copy | |
6 | +of this software and associated documentation files (the "Software"), to deal | |
7 | +in the Software without restriction, including without limitation the rights | |
8 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | +copies of the Software, and to permit persons to whom the Software is | |
10 | +furnished to do so, subject to the following conditions: | |
11 | + | |
12 | +The above copyright notice and this permission notice shall be included in all | |
13 | +copies or substantial portions of the Software. | |
14 | + | |
15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
21 | +SOFTWARE. | ... | ... |
README.md
0 → 100644
1 | +# egg-passport-dingtalk | |
2 | + | |
3 | +[![NPM version][npm-image]][npm-url] | |
4 | +[![build status][travis-image]][travis-url] | |
5 | +[![Test coverage][codecov-image]][codecov-url] | |
6 | +[![David deps][david-image]][david-url] | |
7 | +[![Known Vulnerabilities][snyk-image]][snyk-url] | |
8 | +[![npm download][download-image]][download-url] | |
9 | + | |
10 | +[npm-image]: https://img.shields.io/npm/v/egg-passport-dingtalk.svg?style=flat-square | |
11 | +[npm-url]: https://npmjs.org/package/egg-passport-dingtalk | |
12 | +[travis-image]: https://img.shields.io/travis/eggjs/egg-passport-dingtalk.svg?style=flat-square | |
13 | +[travis-url]: https://travis-ci.org/eggjs/egg-passport-dingtalk | |
14 | +[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-passport-dingtalk.svg?style=flat-square | |
15 | +[codecov-url]: https://codecov.io/github/eggjs/egg-passport-dingtalk?branch=master | |
16 | +[david-image]: https://img.shields.io/david/eggjs/egg-passport-dingtalk.svg?style=flat-square | |
17 | +[david-url]: https://david-dm.org/eggjs/egg-passport-dingtalk | |
18 | +[snyk-image]: https://snyk.io/test/npm/egg-passport-dingtalk/badge.svg?style=flat-square | |
19 | +[snyk-url]: https://snyk.io/test/npm/egg-passport-dingtalk | |
20 | +[download-image]: https://img.shields.io/npm/dm/egg-passport-dingtalk.svg?style=flat-square | |
21 | +[download-url]: https://npmjs.org/package/egg-passport-dingtalk | |
22 | + | |
23 | +<!-- | |
24 | +Description here. | |
25 | +--> | |
26 | + | |
27 | +## Install | |
28 | + | |
29 | +```bash | |
30 | +$ npm i egg-passport-dingtalk --save | |
31 | +``` | |
32 | + | |
33 | +## Usage | |
34 | + | |
35 | +```js | |
36 | +// {app_root}/config/plugin.js | |
37 | +exports.passportDingtalk = { | |
38 | + enable: true, | |
39 | + package: 'egg-passport-dingtalk', | |
40 | +}; | |
41 | +``` | |
42 | + | |
43 | +## Configuration | |
44 | + | |
45 | +```js | |
46 | +// {app_root}/config/config.default.js | |
47 | +exports.passportDingtalk = { | |
48 | +}; | |
49 | +``` | |
50 | + | |
51 | +see [config/config.default.js](config/config.default.js) for more detail. | |
52 | + | |
53 | +## Example | |
54 | + | |
55 | +<!-- example here --> | |
56 | + | |
57 | +## Questions & Suggestions | |
58 | + | |
59 | +Please open an issue [here](https://github.com/eggjs/egg/issues). | |
60 | + | |
61 | +## License | |
62 | + | |
63 | +[MIT](LICENSE) | ... | ... |
README.zh_CN.md
0 → 100644
1 | +# egg-passport-dingtalk | |
2 | + | |
3 | +[![NPM version][npm-image]][npm-url] | |
4 | +[![build status][travis-image]][travis-url] | |
5 | +[![Test coverage][codecov-image]][codecov-url] | |
6 | +[![David deps][david-image]][david-url] | |
7 | +[![Known Vulnerabilities][snyk-image]][snyk-url] | |
8 | +[![npm download][download-image]][download-url] | |
9 | + | |
10 | +[npm-image]: https://img.shields.io/npm/v/egg-passport-dingtalk.svg?style=flat-square | |
11 | +[npm-url]: https://npmjs.org/package/egg-passport-dingtalk | |
12 | +[travis-image]: https://img.shields.io/travis/eggjs/egg-passport-dingtalk.svg?style=flat-square | |
13 | +[travis-url]: https://travis-ci.org/eggjs/egg-passport-dingtalk | |
14 | +[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-passport-dingtalk.svg?style=flat-square | |
15 | +[codecov-url]: https://codecov.io/github/eggjs/egg-passport-dingtalk?branch=master | |
16 | +[david-image]: https://img.shields.io/david/eggjs/egg-passport-dingtalk.svg?style=flat-square | |
17 | +[david-url]: https://david-dm.org/eggjs/egg-passport-dingtalk | |
18 | +[snyk-image]: https://snyk.io/test/npm/egg-passport-dingtalk/badge.svg?style=flat-square | |
19 | +[snyk-url]: https://snyk.io/test/npm/egg-passport-dingtalk | |
20 | +[download-image]: https://img.shields.io/npm/dm/egg-passport-dingtalk.svg?style=flat-square | |
21 | +[download-url]: https://npmjs.org/package/egg-passport-dingtalk | |
22 | + | |
23 | +<!-- | |
24 | +Description here. | |
25 | +--> | |
26 | + | |
27 | +## 依赖说明 | |
28 | + | |
29 | +### 依赖的 egg 版本 | |
30 | + | |
31 | +egg-passport-dingtalk 版本 | egg 1.x | |
32 | +--- | --- | |
33 | +1.x | 😁 | |
34 | +0.x | ❌ | |
35 | + | |
36 | +### 依赖的插件 | |
37 | +<!-- | |
38 | + | |
39 | +如果有依赖其它插件,请在这里特别说明。如 | |
40 | + | |
41 | +- security | |
42 | +- multipart | |
43 | + | |
44 | +--> | |
45 | + | |
46 | +## 开启插件 | |
47 | + | |
48 | +```js | |
49 | +// config/plugin.js | |
50 | +exports.passportDingtalk = { | |
51 | + enable: true, | |
52 | + package: 'egg-passport-dingtalk', | |
53 | +}; | |
54 | +``` | |
55 | + | |
56 | +## 使用场景 | |
57 | + | |
58 | +- Why and What: 描述为什么会有这个插件,它主要在完成一件什么事情。 | |
59 | +尽可能描述详细。 | |
60 | +- How: 描述这个插件是怎样使用的,具体的示例代码,甚至提供一个完整的示例,并给出链接。 | |
61 | + | |
62 | +## 详细配置 | |
63 | + | |
64 | +请到 [config/config.default.js](config/config.default.js) 查看详细配置项说明。 | |
65 | + | |
66 | +## 单元测试 | |
67 | + | |
68 | +<!-- 描述如何在单元测试中使用此插件,例如 schedule 如何触发。无则省略。--> | |
69 | + | |
70 | +## 提问交流 | |
71 | + | |
72 | +请到 [egg issues](https://github.com/eggjs/egg/issues) 异步交流。 | |
73 | + | |
74 | +## License | |
75 | + | |
76 | +[MIT](LICENSE) | ... | ... |
app.js
0 → 100644
1 | +'use strict'; | |
2 | + | |
3 | +const debug = require('debug')('egg-passport-dingtalk'); | |
4 | +const assert = require('assert'); | |
5 | +const Strategy = require('node-passport-dingtalk').Strategy; | |
6 | + | |
7 | +module.exports = app => { | |
8 | + const config = app.config.passportDingtalk; | |
9 | + config.passReqToCallback = true; | |
10 | + assert(config.key, '[egg-passport-twitter] config.passportDingtalk.key required'); | |
11 | + assert(config.secret, '[egg-passport-twitter] config.passportDingtalk.secret required'); | |
12 | + config.clientID = config.key; | |
13 | + config.clientSecret = config.secret; | |
14 | + | |
15 | + // must require `req` params | |
16 | + app.passport.use('dingtalk', new Strategy(config, (req, token, tokenSecret, params, profile, done) => { | |
17 | + // format user | |
18 | + const user = { | |
19 | + provider: 'dingtalk', | |
20 | + id: profile.id, | |
21 | + name: profile.username, | |
22 | + displayName: profile.displayName, | |
23 | + photo: profile.photos && profile.photos[0] && profile.photos[0].value, | |
24 | + token, | |
25 | + tokenSecret, | |
26 | + params, | |
27 | + profile, | |
28 | + }; | |
29 | + debug('%s %s get user: %j', req.method, req.url, user); | |
30 | + | |
31 | + // let passport do verify and call verify hook | |
32 | + app.passport.doVerify(req, user, done); | |
33 | + })); | |
34 | +}; | ... | ... |
appveyor.yml
0 → 100644
1 | +environment: | |
2 | + matrix: | |
3 | + - nodejs_version: '8' | |
4 | + - nodejs_version: '10' | |
5 | + | |
6 | +install: | |
7 | + - ps: Install-Product node $env:nodejs_version | |
8 | + - npm i npminstall && node_modules\.bin\npminstall | |
9 | + | |
10 | +test_script: | |
11 | + - node --version | |
12 | + - npm --version | |
13 | + - npm run test | |
14 | + | |
15 | +build: off | ... | ... |
config/config.default.js
0 → 100644
1 | +'use strict'; | |
2 | + | |
3 | +/** | |
4 | + * egg-passport-dingtalk default config | |
5 | + * @member Config#passportDingtalk | |
6 | + * @property {String} SOME_KEY - some description | |
7 | + */ | |
8 | +exports.passportDingtalk = { | |
9 | + key: 'dingkuvhxslusd5hkjem', | |
10 | + secret: 'Eyv_4w3DtafgN0b-EuHDWC0aty1RfOq55pJlBMiKkL64iNSF67AtU3aBcJNM-0ds', | |
11 | + callbackURL: '/callback/dingtalk', | |
12 | +}; | ... | ... |
package-lock.json
0 → 100644
此 diff 太大无法显示。
package.json
0 → 100644
1 | +{ | |
2 | + "name": "egg-passport-dingtalk", | |
3 | + "version": "1.0.0", | |
4 | + "description": "dingtalk passport plugin for egg", | |
5 | + "eggPlugin": { | |
6 | + "name": "passportDingtalk", | |
7 | + "dependencies": [ | |
8 | + "passport" | |
9 | + ] | |
10 | + }, | |
11 | + "keywords": [ | |
12 | + "egg", | |
13 | + "eggPlugin", | |
14 | + "egg-plugin", | |
15 | + "egg-passport", | |
16 | + "passport-dingtalk" | |
17 | + ], | |
18 | + "dependencies": { | |
19 | + "debug": "^2.6.1", | |
20 | + "node-passport-dingtalk": "^2.0.7" | |
21 | + }, | |
22 | + "devDependencies": { | |
23 | + "autod": "^3.0.1", | |
24 | + "autod-egg": "^1.1.0", | |
25 | + "egg": "^2.16.0", | |
26 | + "egg-bin": "^4.11.0", | |
27 | + "egg-ci": "^1.11.0", | |
28 | + "egg-mock": "^3.21.0", | |
29 | + "egg-passport": "^2.1.1", | |
30 | + "eslint": "^5.13.0", | |
31 | + "eslint-config-egg": "^7.1.0", | |
32 | + "supertest": "^3.0.0" | |
33 | + }, | |
34 | + "engines": { | |
35 | + "node": ">=8.0.0" | |
36 | + }, | |
37 | + "scripts": { | |
38 | + "test": "npm run lint -- --fix && egg-bin pkgfiles && npm run test-local", | |
39 | + "test-local": "egg-bin test", | |
40 | + "cov": "egg-bin cov", | |
41 | + "lint": "eslint .", | |
42 | + "ci": "egg-bin pkgfiles --check && npm run lint && npm run cov", | |
43 | + "pkgfiles": "egg-bin pkgfiles", | |
44 | + "autod": "autod" | |
45 | + }, | |
46 | + "files": [ | |
47 | + "config", | |
48 | + "app.js" | |
49 | + ], | |
50 | + "ci": { | |
51 | + "version": "8, 10" | |
52 | + }, | |
53 | + "repository": { | |
54 | + "type": "git", | |
55 | + "url": "git+https://github.com/eggjs/egg-passport-dingtalk.git" | |
56 | + }, | |
57 | + "bugs": { | |
58 | + "url": "https://github.com/eggjs/egg/issues" | |
59 | + }, | |
60 | + "homepage": "https://github.com/eggjs/egg-passport-dingtalk#readme", | |
61 | + "author": "", | |
62 | + "license": "MIT" | |
63 | +} | ... | ... |
test/passport-dingtalk.test.js
0 → 100644
1 | +'use strict'; | |
2 | +const request = require('supertest'); | |
3 | +const mock = require('egg-mock'); | |
4 | + | |
5 | +describe('test/passport-dingtalk.test.js', () => { | |
6 | + let app; | |
7 | + before(() => { | |
8 | + app = mock.app({ | |
9 | + baseDir: 'apps/passport-dingtalk-test', | |
10 | + }); | |
11 | + return app.ready(); | |
12 | + }); | |
13 | + | |
14 | + after(() => app.close()); | |
15 | + afterEach(mock.restore); | |
16 | + | |
17 | + it('should GET /', () => { | |
18 | + return request(app.callback()) | |
19 | + .get('/') | |
20 | + .expect('hi, passportDingtalk') | |
21 | + .expect(200); | |
22 | + }); | |
23 | +}); | ... | ... |
请
注册
或
登录
后发表评论