egg-serverless-inner-auth
v1.2.1
Published
* 1、在plugin启用插件 ```js innerAuth: { enable: true, package: 'egg-serverless-inner-auth', }, ``` * 2、参数配置 ```js config.serverlessInnerAuth = { //需要验证的前缀 prefix: "inner", //密钥 secret: "", //内网域名 host: "http://localhost",
Downloads
29
Readme
使用
- 1、在plugin启用插件
innerAuth: {
enable: true,
package: 'egg-serverless-inner-auth',
},
- 2、参数配置
config.serverlessInnerAuth = {
//需要验证的前缀
prefix: "inner",
//密钥
secret: "",
//内网域名
host: "http://localhost",
//有效时长(s)
expire: 10,
//返回状态码
status: 200,
//返回信息
message: '内部错误',
//返回信息内的code
code: 1001
};
- 3、启用中间件
// 中间件
config.middleware = ['innerAuthority'];
- 4、调用请求方法
//域名及前缀都在配置里,如请求 http://127.0.0.1/inner/order
const data = await this.app.innerRequest('/order', {})