node-oauth2-server plugin for Egg.js.
npm i @axolo/egg-oauth --save
// {app_root}/config/plugin.js
exports.oauth = {
enable: true,
package: '@axolo/egg-oauth',
};
// {app_root}/config/config.default.js
exports.oauth = {
client: {
OAuth2Sever: require('oauth2-server'), // user defined oauth2-server version
model: require('./oauth-model'), // model require
accessTokenLifetime: 7200, // default 3600
requireClientAuthentication: {
password: false,
},
},
};
MUST build OAuth2 Model Specification at model in config by yourselves.
see config/config.default.js for more detail.
props | description |
---|---|
OAuth2Server | class of OAuth2Server |
Response | class of OAuth2Server.Response |
Request | class of OAuth2Server.Request |
A example of model.
// app/config/oauth-model.js
module.exports = (options, app) => ({
getClient: (clientId, clientSecret) => {
return { clientId, clientSecret };
},
// ...
});
- get
request
inmodel
Please open an issue here.