fix: remove temporary role whitelist and add permission denial logging
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -67,12 +67,6 @@ def permission_required(permission_code):
|
||||
if user_role == 'super_admin':
|
||||
return fn(*args, **kwargs)
|
||||
|
||||
# TODO: 临时开发白名单 - 在数据库权限配置完备后,请删除此段代码
|
||||
# 允许 admin 和 manager 角色直接访问所有接口,避免开发阶段阻塞
|
||||
if user_role in ['admin', 'manager']:
|
||||
logging.info(f"临时白名单放行: 角色 {user_role} 访问需要权限 {permission_code}")
|
||||
return fn(*args, **kwargs)
|
||||
|
||||
# 根据角色查询数据库中的权限
|
||||
try:
|
||||
from app.services.auth_service import AuthService
|
||||
@ -85,6 +79,7 @@ def permission_required(permission_code):
|
||||
all_perms = perm_dict.get('menus', []) + perm_dict.get('elements', [])
|
||||
if permission_code not in all_perms:
|
||||
# 详细的调试日志
|
||||
print(f"🔴 [权限拦截] 角色 '{user_role}' 访问被拒!需要权限码: '{permission_code}', 但该角色实际拥有: {all_perms}")
|
||||
logging.warning(
|
||||
f"权限检查失败: 角色={user_role}, 所需权限={permission_code}, 实际权限列表={all_perms}")
|
||||
return jsonify(msg='权限不足:您没有访问此资源的权限'), 403
|
||||
|
||||
Reference in New Issue
Block a user