Files
mayfly-go/docs/server/security.md
2026-05-08 20:45:13 +08:00

27 lines
520 B
Markdown
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.
---
trigger: always_on
---
# 安全与权限规范
## 权限控制
```go
// 路由级别
req.NewPost(":dbId/exec-sql", d.ExecSql).RequiredPermissionCode("db:sqlscript:run")
// 代码级别
biz.IsTrue(account.HasPermission("db:sqlscript:run"), "无权限执行SQL")
```
## 敏感信息
- 资源密码使用 AES 加密存储
- `aes.key``jwt.key` 必须使用随机字符串
## OWASP 安全准则
- 防范 SQL 注入:使用参数化查询
- 防范 XSS输出转义
- 防范 CSRF配合前端同源策略