egg-authing

1.0.2 • Public • Published

egg-authing

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-authing --save

Usage

To enable Authing plugin, you should change ${baseDir}/config/plugin.js

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

Configuration

Single Instance

// {app_root}/config/config.default.js
exports.authing = {
  client: {
    clientId: '',
    secret: ''
  }
};

Multiple Instances

// {app_root}/config/config.default.js
exports.authing = {
  clients: {
    pool1:{
      clientId: 'your_client_id',
      secret: 'your_client_secret'
    },
    pool2: {
      clientId: 'your_client_id',
      secret: 'your_client_secret'
    }
  }
};

see config/config.default.js for more detail.

Example

  const { ctx } = this;
  const user = await ctx.authing.login({
    email: 'test@testmail.com',
        password: 'testpassword'
  });
  //Multiple instances example
  const { ctx } = this;
  const userPool1 = await ctx.authing.get('pool1').login({
    email: 'test@testmail.com',
        password: 'testpassword'
  });
  const userPool2 = await ctx.authing.get('pool2').login({
    email: 'test@testmail.com',
        password: 'testpassword'
  });

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-authing

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.68 kB

Total Files

7

Last publish

Collaborators

  • s9n