@axolo/egg-oauth

0.1.6 • Public • Published

egg-oauth

node-oauth2-server plugin for Egg.js.

Install

npm i @axolo/egg-oauth --save

Usage

// {app_root}/config/plugin.js
exports.oauth = {
  enable: true,
  package: '@axolo/egg-oauth',
};

Configuration

// {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

props description
OAuth2Server class of OAuth2Server
Response class of OAuth2Server.Response
Request class of OAuth2Server.Request

model

A example of model.

// app/config/oauth-model.js
module.exports = (options, app) => ({
  getClient: (clientId, clientSecret) => {
    return { clientId, clientSecret };
  },
  // ...
});

TODO

  • get request in model

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i @axolo/egg-oauth

Weekly Downloads

3

Version

0.1.6

License

MIT

Unpacked Size

6.98 kB

Total Files

6

Last publish

Collaborators

  • axolo