Skip to content

Commit

Permalink
feat: support user whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
jianxun.zxl committed Jul 9, 2024
1 parent be3260a commit d23d372
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/config_default.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ module.exports = {
* @type {Object} 发布的包的存储设置,支持oss、minio
*/
storage: null,
/**
* 白名单,如需限制用户访问,设置这个列表
* {"username": true, "username2": true}
*/
userWhiteList: null,
/**
* 设置是否开启通过Oss来实现publish的上传功能
* @type {Boolean}
*/
enableOssPublish: false,
/**
* 开启cluster检查严格模式,fixCluster的时候会检查clusterCode是否相等
* 注意 honeycomb-server侧记得配置 config.cluster=${clusterCode},否则机器会被踢出集群
*/
clusterCheckStrict: false,
logs: {},
salt: null,
/**
Expand Down
6 changes: 6 additions & 0 deletions middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ module.exports = function (app, options) {
}
// if already login
if (req.session && req.session.username) {
if (config.userWhiteList && !config.userWhiteList[req.session.username]) {
return res.status(403).json({
code: 'FORBIDDEN',
message: 'Forbidden'
});
}
if (path === '/logout') {
req.session.user = null;
req.session = null;
Expand Down

0 comments on commit d23d372

Please # to comment.