egg-xauth

Authing plugin for egg

Usage no npm install needed!

<script type="module">
  import eggXauth from 'https://cdn.skypack.dev/egg-xauth';
</script>

README

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