egg-deepexi-jwt

1.1.0 • Public • Published

deepexi-egg-jwt

NPM version build status Test coverage Known Vulnerabilities

Deepexi Egg's JWT(JSON Web Token Authentication Plugin)

Install

$ npm i egg-deepexi-jwt --save

or

yarn add egg-deepexi-jwt

Usage

// {app_root}/config/plugin.js
exports.jwt = {
  enable: true,
  package: "egg-deepexi-jwt"
};

Configuration

// {app_root}/config/config.default.js
exports.jwt = {
    enable: true,
    enableParse: true,
    enableSignature: false,
    // if you don't like this way 
    // you can use in app/router.js 
    whiteUrls: ['/test'],
};

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

Example

// app/router.js
"use strict";
 
module.exports = app => {
  app.get('/test',app.controller.test.index);
 // if you want use middleware
  app.get('/test',app.middleware.jwt(),app.controller.test.index);
};
// app/controller/test.js
("use strict");
 
module.exports = app => {
  class SuccessController extends app.Controller {
    index() {
         console.log('query body : ', this.ctx.query);
         this.ctx.body = this.ctx.query;
    }
  }
  return SuccessController;
};

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-deepexi-jwt

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

8.5 kB

Total Files

10

Last publish

Collaborators

  • jackyhweng