|
|
4808a48594
|
refactor(audit): 审计架构清理——复活白名单监听器、停用噪声监听器、清除僵尸装饰器
一、统一为单一监听器实现
原先两套 SQLAlchemy 事件监听器并存:
· app/utils/audit_events.py —— 全局监听 db.Model、无白名单、无请求上下文守卫(实际在跑)
· app/core/audit_listener.py —— 白名单制、有守卫、有模型级开关(从未生效)
后者失效的根因:注册代码写在 extensions.py 的 init_extensions() 内,
而该函数全仓库只有定义、没有任何调用(create_app 直接内联调用 db.init_app 等)。
现统一由 app/core/audit_listener.py 承担,并在 create_app() 中显式注册。
extensions.py 的死函数 init_extensions 整体删除,避免后人误以为它是有效入口。
二、修复监听器三处致命缺陷(此前注册了也写不进数据)
1. 事件回调第二个参数是 Connection,原代码却调用 Connection.add()(不存在),
每次写日志都抛 AttributeError 并被 except 吞掉 → 改为 connection.execute()
2. register_audit_listeners 从 app.models 批量 import 多个未导出的模型,
ImportError 被上层 try/except 吞掉 → 改为按表名从 db.metadata 取模型
3. 本项目有 31 处函数体内延迟导入模型(如 scrap.py 内部才 import ScrapApproval),
一次性注册会静默漏表 → 增加 ensure_audit_listeners() 惰性补绑,
并在模型预加载段补全审批单/BOM/采购等模型
三、强约束
· WHITELIST_TABLES:仅 18 张核心业务表,系统表/草稿表/向量表不再自审
· has_request_context() 守卫:系统初始化与后台定时任务不再产生 username=system 噪声
· IGNORE_FIELDS 增加 password/password_hash/salt/token/secret/api_key(安全红线)
· created_at 显式写 beijing_time(),与全系统时间口径一致
四、清除僵尸装饰器
@audit_log 早已退化为直接透传的空壳(module/action 参数全被忽略,
数据库中零星的中文 action 即其历史遗留产物),却仍挂在 38 处路由上。
连同 13 个文件的 import 一并移除;audit_events.register_audit_events 改为空操作。
验证:应用上下文中的写操作不产生日志;HTTP 请求产生 5 条日志,
对象为业务单号(APR-SCRAP-... / SKU),模块中文,操作人真实,时间为北京时间。
|
2026-09-10 14:16:27 +08:00 |
|
|
|
cd600f9fc2
|
fix(auth): 审批人列表按公司收窄——本公司主管 + 所有超管
- get_approvers:普通/主管仅见 department=本人公司 的 SUPERVISOR 与全部 SUPER_ADMIN;超管本人不受限
|
2026-09-09 15:23:51 +08:00 |
|
|
|
d75c301556
|
fix: batch_create_user 补上缺失的 permission_required(system_user:operation)
|
2026-07-15 09:22:58 +08:00 |
|
|
|
4f5965db02
|
feat: JWT多租户数据权限隔离 & 主管系统管理权限 & 含税单价补齐
## 多租户公司数据隔离
- 新增 get_current_company_filter() 工具函数 (decorators.py)
SUPER_ADMIN: 可传company_name参数过滤或传ALL看全量
其他角色: 强制隔离到JWT中的company_name
- 重构 base_service.py / buy_service.py: 用集中式函数替换内联公司过滤
- SysRolePermission 表新增 company_name 字段,支持同角色不同公司权限
- get_user_permissions() 新增 company_name 参数,查公司定制+全局模板权限
- permission.py API 新增 @permission_required 拦截 + 公司过滤
- 19个API/service文件传递 company_name 到权限查询
## 主管系统管理权限
- delete_user() 允许SUPERVISOR删除同公司用户 (原仅SUPER_ADMIN)
- get_all_users() 新增 company_name 参数过滤
- 用户列表/权限分配 API 应用 get_current_company_filter()
- 前端 UserCreate.vue: 超管可见公司下拉框,主管隐藏部门字段
## 前端多租户适配
- material/list.vue / buy.vue: 公司下拉框仅超管可见,默认ALL
- UserCreate.vue: 新增搜索栏公司筛选,部门字段按角色显隐
- auth.ts: getUserList() 支持 params 参数
## Bug修复: 含税单价字段补齐
- buy.vue: 表格列/高级筛选/排序/权限映射新增 post_tax_unit_price
- buy_service.py: allowed_fields/sort_field_map 新增 post_tax_unit_price
|
2026-07-13 15:12:22 +08:00 |
|
|
|
3dae206828
|
feat(outbound): 完善出库审批邮件通知逻辑,支持申请人与审批人同时收到邮件(带物料明细),审批通过后申请人和库管均收到带物料明细的通知
|
2026-05-12 13:42:15 +08:00 |
|
|
|
62c0e3738e
|
fix(outbound+trans): 修复POST接口错误数据清洗导致的sku/quantity字段被清除Bug,并新增出库审批工作流全链路
|
2026-04-28 16:02:34 +08:00 |
|
|
|
772f3f45f4
|
feat(profile): implement independent email update dialog to prevent accidental password resets during partial updates
|
2026-04-17 12:48:30 +08:00 |
|
|
|
d651d19e86
|
feat(system): implement robust batch user creation integrating existing pinyin logic and backend duplication prevention
|
2026-04-17 12:16:45 +08:00 |
|
|
|
e1006f383a
|
refactor: global import cleanup and stability fix for auth module
|
2026-03-23 13:43:29 +08:00 |
|
|
|
505b8e5a32
|
fix: add missing get_jwt import to resolve NameError in my-permissions API
|
2026-03-23 13:41:13 +08:00 |
|
|
|
0bdd4c068e
|
fix: add missing db import to resolve NameError in password update API
|
2026-03-23 13:38:18 +08:00 |
|
|
|
61ec906cfb
|
fix: resolve 500 error in password update API by aligning schema and fixing hash logic
|
2026-03-23 13:32:53 +08:00 |
|
|
|
719fe108ba
|
feat: remove old password requirement, fix user info display, and add password change reminder on home page
|
2026-03-23 11:52:30 +08:00 |
|
|
|
ec5331ffb3
|
feat: fix table alignment in product view and implement self-service password update with role masking
|
2026-03-23 11:41:09 +08:00 |
|
|
|
032479fe38
|
fix: capture and persist target object names for delete, outbound, and borrow operations in audit logs
|
2026-03-20 15:47:13 +08:00 |
|
|
|
de0a5c8db2
|
全局审计日志
|
2026-03-10 17:27:54 +08:00 |
|
|
|
e4632086a1
|
feat: 重构鉴权系统为双Token无感刷新,并增加前端Token过期安全预判机制
|
2026-03-10 09:45:41 +08:00 |
|
|
|
a0993767fe
|
fix: make SUPER_ADMIN role checks case-insensitive across app
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
|
2026-02-27 17:04:22 +08:00 |
|
|
|
4324e5a688
|
feat: add field-level data protection for BOM and user management
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
|
2026-02-27 15:16:11 +08:00 |
|
|
|
00c45c72fb
|
inventory-web/src/views/system/UserCreate.vue
```vue
<<<<<<< SEARCH
<el-button type="primary" @click="handleCreate">
+ 新增员工
</el-button>
=======
<el-button v-if="userStore.hasPermission('system_user:operation')" type="primary" @click="handleCreate">
+ 新增员工
</el-button>
>>>>>>> REPLACE
```
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
|
2026-02-27 14:34:48 +08:00 |
|
|
|
6fa5233ea6
|
feat: implement RBAC and field masking for system_user module
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
|
2026-02-27 14:28:48 +08:00 |
|
|
|
7431f1f41e
|
权限管理,没有页面修改之前版本
|
2026-02-25 16:10:12 +08:00 |
|
|
|
596f366fc4
|
进入界面的调整
|
2026-02-04 15:55:20 +08:00 |
|
|
|
c1c525b699
|
登录界面调整
|
2026-02-04 15:41:51 +08:00 |
|
|
|
ea17413bc1
|
新增用户页面更新以及调整
|
2026-02-04 15:16:14 +08:00 |
|
|
|
fd5600b65b
|
修改登录退出逻辑
|
2026-02-04 14:29:59 +08:00 |
|
|
|
13590b1fac
|
超级管理员登录设置
|
2026-02-04 13:30:07 +08:00 |
|
|
|
ee9f4aed3e
|
修正git管理关系
|
2026-01-26 13:47:53 +08:00 |
|