Repository navigation
Three route groups that skipped the role check are fixed, the code generator's routes now go through it, and the SQLite quick start works from a fresh clone. Run migrate when you upgrade; read the section below first.
⚠️ Before you upgrade
1. Run migrate. Two migrations are new, 1786700011000 and 1786700012000. They bind the code generator's APIs, /role-status, /job/start and /job/remove to the menus that expose them, and grant them to every role that already holds one of those menus. Without them, a non-admin role holding those menus is refused by the endpoints the pages call. #955 #962
2. Five routes now require a login and a role check. GET /api/v1/job/start/:id and /job/remove/:id had neither; PUT /api/v1/role-status, PUT /api/v1/roledatascope and GET/PUT /api/v1/set-config only checked the login. If a script or an external scheduler calls the two job routes without a token, it now gets 401 and must send one. A role without the matching menu (修改角色, 参数设置, or the job menus) now gets 403 from them; give it the menu to restore access. admin is unaffected. #962
3. Every code generator route goes through the role check. Before, any account that could log in reached all thirteen. A role that holds 代码生成 or 代码生成修改 keeps working after migrate; a role that holds neither now gets 403. #955
- 🔒 Security
- 🔒
/job/start/:idand/job/remove/:idran without authentication, so an anonymous request could start or stop a scheduled job. #962 - 🔒
PUT /role-status,PUT /roledatascopeand/set-configchecked the login but not the role, so any logged-in user could change another role's status or data scope, and read and overwrite the system settings. #962 - 🔒 The code generator's writes stay inside the working directory and
gen.frontpath, symlinks included, and its package, table and business names are validated on the server on import, save and generate. #955 - 🔒 All thirteen code generator routes go through the role check; the captcha stays public. #955
- 🔒
- Generic CRUD actions
- ✨
actions.Index,View,ViewAs,Create,UpdateandDeleteare type-parameterised, so a model paired with the wrong request does not compile and a request no longer has to return a copy of itself.app/demoandapp/jobsuse them, the old five actions are markedDeprecatedand behave as before, andAGENTS.mdanddocs/contract.mdteach the new ones. #956 - 🐛 Queries were given the pooled
*gin.Contextas their context, which gin hands to the next request when the handler returns. Writes could race with it on SQLite and PostgreSQL; they now usec.Request.Context(). #956 - 🐛 The new actions answer 500 instead of an empty 200 when there is no database, and match the key as a value instead of handing a string to
Where. #956
- ✨
- SQLite
- ✨ Seed SQL is embedded in the binary, so
migrateon an empty database no longer depends on the working directory containingconfig/. A file on disk still wins. #961 - 🐛 SQLite connections get a busy timeout, WAL,
synchronous=NORMALand immediate transactions unless the source sets them, which stopsdatabase is lockedunder concurrent reads and writes. #961 - 📝 The README's init command pointed at
config/settings.dev.yml, which does not exist; it isconfig/settings.ymlin all four READMEs. The startup section opens with a three-command SQLite quick start, and a default build that is given asqlite3config now says to rebuild with-tags sqlite3. #960
- ✨ Seed SQL is embedded in the binary, so
- 🔧 The code generator's unused
template/v4/actionsrouter templates are removed. #957 - ✅ Tests cover the operation log's truncation on a character boundary. #959
三组漏掉角色校验的路由已修复,代码生成器的路由也改为经过角色校验,SQLite 快速开始现在从全新克隆就能跑通。升级时需要执行 migrate,请先读下面这一节。
⚠️ 升级前
1. 执行 migrate。 新增 2 个迁移:1786700011000 和 1786700012000。它们把代码生成器的接口、/role-status、/job/start、/job/remove 绑定到暴露它们的菜单,并授予已持有这些菜单的角色。不执行的话,持有这些菜单的非 admin 角色会被页面调用的接口拒绝。#955 #962
2. 五个路由现在要求登录并检查角色。 GET /api/v1/job/start/:id 和 /job/remove/:id 此前两者都没有;PUT /api/v1/role-status、PUT /api/v1/roledatascope 和 GET/PUT /api/v1/set-config 此前只检查登录。如果有脚本或外部调度器不带 token 调用这两个任务路由,现在会得到 401,需要带上 token。没有对应菜单(修改角色、参数设置或定时任务菜单)的角色现在会得到 403,授予菜单即可恢复。admin 不受影响。#962
3. 代码生成器的所有路由都经过角色校验。 此前任何能登录的账号都能访问全部 13 个。持有"代码生成"或"代码生成修改"菜单的角色在 migrate 之后照常使用;两个菜单都没有的角色现在得到 403。#955
- 🔒 安全
- 泛型 CRUD Action
- ✨
actions.Index、View、ViewAs、Create、Update、Delete带类型参数:模型与请求配错无法通过编译,请求也不再需要返回自身的副本。app/demo和app/jobs已改用它们,原有五个 Action 标记为Deprecated且行为不变,AGENTS.md和docs/contract.md改为介绍新的。#956 - 🐛 查询把被池化的
*gin.Context当作查询上下文传入,而 gin 在 handler 返回后会把它交给下一个请求。SQLite 和 PostgreSQL 上写操作可能与之竞争;现在改用c.Request.Context()。#956 - 🐛 新的 Action 在没有数据库时返回 500 而不是空的 200,并把主键当作值匹配,而不是把字符串交给
Where。#956
- ✨
- SQLite
- ✨ 种子 SQL 内嵌在二进制中,空库上执行
migrate不再依赖工作目录里有config/;磁盘上的文件仍然优先。#961 - 🐛 除非数据源自行设置,SQLite 连接默认带 busy timeout、WAL、
synchronous=NORMAL和 immediate 事务,解决并发读写时的database is locked。#961 - 📝 README 的初始化命令指向不存在的
config/settings.dev.yml,四份 README 均改为config/settings.yml;启动说明开头新增三条命令的 SQLite 快速开始;默认构建遇到sqlite3配置时,现在会提示用-tags sqlite3重新构建。#960
- ✨ 种子 SQL 内嵌在二进制中,空库上执行
- 🔧 移除代码生成器里没人使用的
template/v4/actions路由模板。#957 - ✅ 新增测试,覆盖操作日志按字符边界截断。#959