Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

egg-yufu-gameops

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-yufu-gameops

egg yufu gameops plugin

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

egg-yufu-gameops

egg-yufu-gameops plugin 工作台玉符插件

依赖说明

依赖的 egg 版本

开启插件

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

使用场景

  • 通过工作台网关,可以使用此插件,获取访问用户的信息

  • 使用方式,安装后,启用插件,并参考下面的详细配置

详细配置

请到 config/config.default.js 查看详细配置项说明。

// config/config.*.js
module.exports = {
		yufu: {
			header: {
				userId: 'x-user-id', // 用户id的请求头字段
				userName: 'x-user-name', // 用户名的请求头字段
			},
			verifyHeader: (headers) => { return true }, // 校验:校验请求头;
			verifyUser: ({ userId, userName }) => { return true }, // 校验:校验解析出来的用户信息;
			default_id: 1, //	无法解析时默认返回的	id
			default_user: 'rtx-name', //	无法解析时默认返回的	user
			exclude: path => !path, // 判断输入的路径是否为要排除的目录
			handleError: ({ ctx, ret, msg }) => { ctx.body = { ret, msg }; }, // 如何处理错误
			processHeader: (headers) => { return  {}; }, // 自定义header处理,最终数据会加到返回的用户信息里
		},
};

获取当前用户信息

ctx.yufu; // { userId // 用户ID, userName // 用户名, headers // 请求头原始数据 }

提问交流

License

MIT

FAQs

Package last updated on 17 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts