Commit Graph
101 Commits
Author SHA1 Message Date
zhangwenjian 22716e90c1 fix🐛: /getinfo cannot be scoped by a data permission it never receives
Logging in on a deployment with enabledp: true ends on the login page. The
login itself succeeds - sys_login_log records it - and then /api/v1/getinfo
answers 401 "登录失败", which sends the browser straight back.

The query behind it reads:

  SELECT * FROM sys_user WHERE sys_user.user_id = 1 AND 1 = 0 AND deleted_at = 0

The 1 = 0 comes from the data-permission scope. GetInfo asked for a permission
with GetPermissionFromContext, but the group this route sits in installs only
the JWT middleware - no PermissionAction - so nothing ever put one in the
context and what came back was the zero value. An unset scope is not one of the
five recognised ones, and since unknown scopes began failing closed rather than
silently matching every row, that zero value now means "match nothing".

The route was working by accident before, and only on deployments that enable
data permissions: the repository default is enabledp: false, where Permission
returns the query untouched. That is why the local suite and CI are both green
and the demo site is not.

Two different faults, so two different fixes:

/getinfo reads the caller's own row - the id comes from the token. A data
scope answers "whose rows may this user see", so there is nothing left for it
to restrict, and applying one is not a stricter version of the query but a
broken one: DataScopeSelf matches on create_by, and an account is created by
whoever added it, so a scoped self-read would 401 every user who did not create
their own account. It now goes through GetSelf, which does no scoping at all -
which is how GetProfile has always read the same row.

/sys-api is the opposite case. Its three handlers do read the permission, and
they are listing and updating other people's rows, so the middleware belongs
there and was simply missing. Added.

Those four endpoints were found by checking every handler that reads the
permission against the group it is registered on. The check reports four before
this commit and none after.

No test. Both paths need a *gorm.DB with sys_user and sys_role rows before they
reach the line that matters, and this repository's CI has no database - `make
build` is CGO_ENABLED=0 with no sqlite tag. What can be tested is the shape of
the mistake rather than its effect, and that belongs in tools/checksilent as a
rule of its own; it is not in this commit because a site that cannot be logged
into should not wait for it.
2026-09-05 21:24:25 +08:00
zhangwenjian 5b01c9ada8 fix🐛: build the shared jwt middleware instance once in InitMiddleware
Four modules each called AuthInit and built their own instance, so which
one Runtime handed back was decided by whichever module initialised last.
The JwtToken key was also registered as an unbound method expression,
which GetHandlerFunc's type assertion can never match - the key was
registered and unusable at the same time.

The instance is now built once here and registered as a bound closure.
Modules read it back through GetAuthMiddleware, which is fatal rather
than nil when called before InitMiddleware has run: a process without a
JWT middleware should not reach the point of serving a request.

Only one call site needs the instance itself rather than the handler
(admin's /login, for LoginHandler); the thirty-odd MiddlewareFunc() call
sites are unchanged.

Claude-Session: https://claude.ai/code/session_01HPTAw8b8tAdFNFn8rKdPYx
2026-09-05 10:26:54 +08:00
zhangwenjian 8ffde94433 chore🔧: move to go-admin-core v2
Every import of the module changes, not only the seven packages that
moved out of sdk/pkg: Go requires the major version in the path from v2
on. Both happen in one pass —

    go run github.com/go-admin-team/go-admin-core/tools/coreupgrade@v2.0.0 -w -v2 .
    go mod tidy

— which is the command the release notes give, run here as a consumer
would run it. 210 imports across 95 files.

The compatibility shims this used are gone in v2, so the paths that
moved had to move: sdk/pkg/captcha, sdk/pkg/jwtauth and its user
package, sdk/pkg/response and sdk/pkg/casbin.

The count of unformatted files is unchanged at 34, none of them touched
by this: the tool reformats a file only if it was already gofmt clean,
so a migration cannot disappear into whitespace.
2026-08-23 13:26:46 +08:00
zhangwenjian bb34108831 fix🐛: 移除 refresh_token 接口,修复 token 可无限续期问题
close #820

GET /api/v1/refresh_token 用业务 token 即可换取新 token,而续期上限
MaxRefresh 依据的 orig_iat 在每次续期时被一并重置,上限永远无法到达 ——
token 一旦泄露即等同于永久访问权,且无任何吊销手段。

该路由此前还位于 CasbinExclude 中,不受 Casbin 约束,任何角色的已登录用户
都可调用。

官方前端从未使用它:store 中虽有 refreshToken action,但全仓库无一处
dispatch,属死代码。移除不影响正常登录与鉴权流程。

破坏性变更:自行调用该端点实现续期的使用者需改为重新登录。正确的无感续期
应在 go-admin-core 中区分 access token 与 refresh token 后重新实现,不应
沿用此路由。
2026-08-14 21:42:52 +08:00
wenjianzhang 37a5963cd6 perf👌: Optimize go warnings 2023-08-01 22:38:41 +08:00
NaturalGao 1f8babd9e7 fix: fix sys_router && add swag commond 2022-08-25 01:19:55 +08:00
NaturalGao 8e8fe906fd perf: update swag 2022-08-25 01:00:57 +08:00
zhangwenjian 10491f9745 fix🐛: 修复删除部门的问题 (#510) 2021-07-28 08:53:18 +08:00
zhangwenjian a45113258c refactor🎨: update request mode name 2021-07-15 00:43:06 +08:00
zhangwenjian dd5f0c52fb refactor🎨: 修改错误信息提示 2021-06-29 16:33:03 +08:00
zhangwenjian 0f623521c4 refactor🎨:代码生成功能迁移 2021-06-25 11:33:41 +08:00
wenjianzhang 2025809d91 refactor🎨:修改Syspost模块功能 2021-06-24 20:17:58 +08:00
Vincent 7ac941c1d0 bugfix:
1.修正用户修改密码put接口url错误导致的无法修改密码问题
2.修正初始化SQL异常导致部分表无缺省参数问题
2021-06-23 09:46:51 +08:00
zhangwenjian 636294b6f5 refactor🎨: 岗位删除修改为data传值方式 2021-06-20 00:13:17 +08:00
zhangwenjian 372248c819 Merge branch 'dev' 2021-06-13 23:07:37 +08:00
zhangwenjian ed52efaa44 refactor🎨: 修改数据字典路由注册 2021-06-13 21:16:55 +08:00
wenjianzhang cc0dab3cd0 refactor🎨: 开放接口无需认证 2021-06-11 17:30:17 +08:00
zhangwenjian 40668581b8 refactor🎨: 添加登陆验证 2021-06-11 09:26:22 +08:00
zhangwenjian 7c7cd7ef7e refactor🎨: engine 初始化调整 2021-06-11 09:25:35 +08:00
zhangwenjian 1b579fb814 feat: 添加修改角色状态接口 2021-06-09 21:31:31 +08:00
wenjianzhang 9a2c0729f6 refactor🎨: 缩减函数名称 2021-06-07 20:37:01 +08:00
zhangwenjian 6e01c13e1c refactor🎨: 缩减函数名称 2021-06-07 16:38:30 +08:00
zhangwenjian c05cb63bc7 refactor🎨: 改造升级用户管理模块 2021-06-03 09:27:34 +08:00
zhangwenjian a54d4ba0c1 format🥚 代码格式化 2021-05-31 18:10:23 +08:00
wenjianzhang 32d8f4384a feat 参数更新功能 2021-05-28 17:12:55 +08:00
wenjianzhang d69b7807c1 feat 添加修改配置接口 2021-05-27 19:33:41 +08:00
wenjianzhang cc74686108 feat 接口管理模块添加列排序 2021-05-24 16:30:21 +08:00
zhangwenjian 452a561309 feat 数据字典根据key获取 业务页面使用 2021-05-24 07:40:48 +08:00
wenjianzhang 408dcc5057 refactor🎨 部分功能重写 2021-05-21 18:25:51 +08:00
wenjianzhang d0b2e8d03f feat 添加api管理 2021-05-12 18:48:01 +08:00
wenjianzhang a78cc33cd1 feat 重置router 2021-05-11 18:48:44 +08:00
wenjianzhang fea425c36c feat 分离gen router 2021-05-11 18:47:45 +08:00
wenjianzhang 61c89bca8d feat 重置config router 2021-05-11 18:43:52 +08:00
wenjianzhang 76e83de8cd feat 重置dept router 2021-05-11 18:42:56 +08:00
wenjianzhang c9d9350476 feat 分离字典相关路由 2021-05-11 18:42:20 +08:00
wenjianzhang 34a1eea45e feat 重置loginlog router 2021-05-11 18:41:43 +08:00
wenjianzhang c505884cf2 feat 修改删除接口传参方式 2021-05-11 18:40:59 +08:00
wenjianzhang b95f517a4c feat 重置operalog router 2021-05-11 18:39:48 +08:00
wenjianzhang 50da7825bb feat 重置post路由 2021-05-11 18:38:44 +08:00
wenjianzhang 0a3e3be12c feat 添加api管理 2021-05-11 18:35:55 +08:00
wenjianzhang e091603bc8 feat 添加api管理功能 2021-05-10 18:24:47 +08:00
wenjianzhang 65b86353e3 fix🐛 修改合并代码产生的问题 2021-05-10 18:21:11 +08:00
wenjianzhang 5f594d6bae refactor🎨 修改参数删除,由url参数改为body 2021-05-10 18:20:14 +08:00
wenjianzhang 57067907d3 refactor🎨 参数设置删除修改 2021-05-10 17:25:43 +08:00
wenjianzhang bde8148eb1 Merge branch 'dev' of https://github.com/go-admin-team/go-admin into dev 2021-05-10 17:04:33 +08:00
wenjianzhang ae34ff8f82 feat优化router import 2021-05-10 17:02:26 +08:00
zhangwenjian c6a52134b3 feat优化字典数据错误判断写法 2021-05-08 13:53:27 +08:00
wenjianzhang c6d94c03fb feat 更新service 2021-05-07 19:57:45 +08:00
wenjianzhang c6ccd844f5 feat 去除生成方法版本信息 2021-05-07 18:54:11 +08:00
linwenxiang 13ff9d9e63 feat 优化api写法 2021-04-27 10:06:22 +08:00