Commit Graph
25 Commits
Author SHA1 Message Date
naiba f7f8264ec0 fix(auth): always serialize User.Role so admin (role 0) is not omitted
The Role field used json:"role,omitempty". Admin is RoleAdmin = 0, so an
admin profile serialized without a `role` key. The admin-frontend gates the
admin menu (user management, settings) on `role === 0`, and its normalizeRole
helper defaults a missing role to non-admin, so admins lost the admin menu.

Drop omitempty so role 0 is always sent. Add a regression test.
2026-05-31 12:05:11 +00:00
naibaandcloudcode e05700c2f0 feat(jwt): server-side session table with keyId + obfuscated uid claims
Replace the {user_id, ip} claim pair with {keyId, uid}:
- keyId is a 32-byte random id that points to a row in the new
  jwt_sessions table holding the real user id, bound IP, UA hash,
  TokenVersion and expiry.
- uid is the user id encoded through pkg/idcodec; mismatch between
  claim uid and session.UserID trips WAF block on the caller IP.
- identityHandler now rejects unknown/revoked/expired sessions, IP
  drift and stale TokenVersion. Refresh updates session.ExpiresAt.

User.TokenVersion bumps on password change and revokes outstanding
sessions, so a leaked JWT secret alone is no longer enough to forge
a token. JWTSession rows are GC'd every 10 minutes (expired + grace
or revoked >24h). OAuth2 callback shares the same issue path.

Includes regression tests for happy path, mismatched claim uid,
revoked session, TokenVersion bump, IP drift and unknown keyId.

Co-authored-by: cloudcode <cloudcode@users.noreply.github.com>
2026-05-26 03:51:05 +00:00
naiba 6b88cdb012 feat: server transfer rotation 2026-05-25 10:17:34 +00:00
UUBulb 010ae7ef51 fix: member-created services shouldn't be applied to admin resources (#1113) 2025-08-28 22:37:44 +08:00
UUBulb d0f69c424e generate agent_secret for old users (#1021) 2025-03-08 18:47:42 +08:00
UUBulb 2d03c61f38 fix: oauth2 redirect url not consistent (#930)
* fix: oauth2 redirect url not consistent

* only use one redirect uri

* feat: allow to disable password authentication

* generate translation template

* update error

* redirect

* query
2024-12-31 22:29:29 +08:00
naiba 8b9afbf39c feat: 绑定 oauth2 2024-12-28 23:50:59 +08:00
naiba 6dea3e19d2 feat: list & block online users 2024-12-22 01:08:07 +08:00
UUBulb dc0132c9aa feat: user roles (#852)
* [WIP] feat: user roles

* update

* update

* admin handler

* update

* feat: user-specific connection secret

* simplify some logics

* cleanup

* update waf

* update user api error handling

* update waf api

* fix codeql

* update waf table

* fix several problems

* add pagination for waf api

* update permission checks

* switch to runtime check

* 1

* cover?

* some changes
2024-12-22 00:05:41 +08:00
UUBulb e465134c11 update profile api (#16)
* update profile api

* rename

* fix realip assertion

* add waf api
2024-11-23 16:22:22 +08:00
naiba c706950ecc feat: create user, read users, batch delete users 2024-10-22 21:19:30 +08:00
naiba 71891b2d61 refactor: login & refresh token 2024-10-20 14:05:43 +08:00
naiba 37c87bbc07 🎉 init swaggo 2024-10-19 23:14:53 +08:00
naiba 15f4816e1f 🔒️ more secure token generation 2022-12-16 23:34:14 +08:00
ysicing bfe8b7e741 feat(oauth2): add gitea oauth2 support
add gitea oauth2 support

Signed-off-by: ysicing <i@ysicing.me>
2022-10-12 19:34:15 +08:00
naiba d58eb460b2 dashboard v0.13.20 Login with Gitlab、Jihulab 2022-05-26 20:00:20 +08:00
naiba 397817d960 🔖 dashboard v0.12.27 取消用户名unique,有些用户 gitee/github 用户名相同导致无法启动 2022-04-26 22:54:40 +08:00
naiba 892eba3619 ⬆️ dashboard v0.12.26 update gorm fields tags 2022-04-26 12:46:44 +08:00
naiba e40c1d1a6e 🗑 优化无效数据清理 2021-07-19 20:27:21 +08:00
naiba 29cee9865e 🔊 v0.3.0 计划任务(定期备份等场景) 2021-01-19 09:59:04 +08:00
naiba 8cc5d1c32b 💥 v2.0 必须更新面板,新增服务监控 2021-01-16 00:45:49 +08:00
naiba 62fdf18fb7 up(notification): 添加修改删除通知、报警规则 2020-12-19 23:11:16 +08:00
naiba eae55c8b85 修复 go mod 不兼容 2020-12-13 00:43:25 +08:00
奶爸 f2080ed795 持久化Token 2019-12-20 23:58:09 +08:00
奶爸 f2f840de4a Web 服务 2019-12-08 16:59:58 +08:00