feat(agent): 管理端 agent 支持陪诊员并按角色收敛工具
陪诊员身份以 Employee 在职档案为准,显式管理员优先;管理端小程序首次登录会写入 role:['user'],不能据此判断。管理员保留跨用户查询与医院资料写入,陪诊员只开放本人订单查询/改单(归属校验、状态与字段白名单、并发保护)与本人档案,患者档案与财务操作不可用。
This commit is contained in:
+7
-5
@@ -4,7 +4,7 @@ import { DBModel } from "./models/index.js";
|
||||
import { chatTask } from "./agent/bots/bot-escort/task.js";
|
||||
import { adminAgent } from "./agent/bots/bot-escort-admin/agent.js"
|
||||
import { getUserByToken } from "./utils/user_service.js";
|
||||
import { isAdmin } from "./utils/permissions.js";
|
||||
import { resolveEscortAdminRole } from "./utils/permissions.js";
|
||||
import logger from "./utils/logger.js";
|
||||
import { createUserLimiter } from "./middleware/ratelimit.js";
|
||||
import {
|
||||
@@ -201,14 +201,16 @@ export default class WebSocketServerManager {
|
||||
}
|
||||
|
||||
if (msg.agent === 'escort-admin') {
|
||||
// 管理端 agent 含写库/环境变量等高危工具,必须校验管理员角色,防止普通用户越权
|
||||
if (!isAdmin(userInfo)) {
|
||||
send('system', 'error', '无管理员权限', msg.id);
|
||||
// 管理端 agent 按角色收敛工具:管理员可跨用户/写库,陪诊员只能看本人订单。
|
||||
// 身份以 Employee 记录为准,普通 C 端账号不能借 agent 升级权限。
|
||||
const role = await resolveEscortAdminRole(userInfo);
|
||||
if (!role) {
|
||||
send('system', 'error', '当前账号未绑定在职陪诊员档案,请联系管理员开通', msg.id);
|
||||
return;
|
||||
}
|
||||
await adminAgent.streamChat(userInfo, [msg], (source, type, content, id) => {
|
||||
send(source, type, content, id);
|
||||
});
|
||||
}, role);
|
||||
} else {
|
||||
await chatTask.streamChat(userInfo, msg, (source, type, content, id) => {
|
||||
send(source, type, content, id);
|
||||
|
||||
Reference in New Issue
Block a user