accounting/wwwroot/get_user_balance.dspy
yumoqing 89592b9585 security: 财务后台权限收敛到财务角色,堵住全平台余额/账务泄漏
- scripts/load_path.py: 按角色分层重写权限矩阵(any/logined/财务角色/分销商角色),
  默认先清理 /accounting/ 全部旧授权再重建;财务后台(余额台账/账户/科目/分录/日志/
  信用管理/币种汇率)从 logined 收敛到 owner.superuser/admin/account +
  reseller.admin/accountant/operator;客户自服务页(已按本机构过滤)保留 logined
- accounting/init.py get_accdetail: 补 account.orgid=当前机构 过滤,堵按 accountid 越权查明细
- wwwroot/get_user_balance.dspy: 改为只查登录用户本人余额(原可按任意 username 查他人余额,
  且存在 swait 拼写错误导致 500)
2026-08-27 18:13:15 +08:00

26 lines
615 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 安全:只允许查询登录用户本人的余额。
# 历史问题:外部传任意 username 即可查询他人余额(且原文件有 swait 拼写错误,一调用就 500
userid = await get_user()
env = request._run_ns
async with get_sor_context(env, 'accounting') as sor:
sql = """select
d.username,
c.name,
a.balance
from account a, subject c, users d
where a.orgid = d.orgid
and a.subjectid = c.id
and d.id = ${userid}$
"""
recs = await sor.sqlExe(sql, {'userid': userid})
return {
'status': 'ok',
'data': recs
}
return {
'status': 'error',
'data': {
'message': 'system error'
}
}