egg-oauth2-server
时间紧张,Fork & Publish 只为个人使用,请支持原版。。
Install
$ npm i egg-oauth2-server --save
Usage
// {app_root}/config/plugin.jsexportsoAuth2Server = enable: true package: 'egg-oauth2-server'; // {app_root}/app/router.jsappall'/user/token' appoAuth2Server;app;app;
Configuration
// {app_root}/config/config.default.jsmodule { const exports = {}; exportsoAuth2Server = debug: configenv === 'local' grants: 'password' ; return exports;};
See test/fixtures/apps/oauth2-server-test/config/config.unittest.js for reference.
Full description see https://www.npmjs.com/package/oauth2-server.
Implementation Example
A simple implementation of password mode OAuth 2.0 server, see test/fixtures/apps/oauth2-server-test/app/extend/oauth.js
// {app_root}/app/extend/oauth.js'use strict'; module { {} async {} async {} async {} async {} async {} async {} async {} async {} return Model;};
Full description see https://www.npmjs.com/package/oauth2-server.
app.oauth.token()
lifecycle
password mode getClient
--> getUser
--> saveToken
app.oauth.authenticate()
lifecycle
password mode Only getAccessToken
app.oauth.authorize()
lifecycle
authorization_code mode getClient
--> getUser
--> saveAuthorizationCode
app.oauth.token()
lifecycle
authorization_code mode getClient
--> getAuthorizationCode
--> saveToken
--> revokeAuthorizationCode
app.oauth.authenticate()
lifecycle
authorization_code mode Only getAccessToken
Questions & Suggestions
Please open an issue here.