Commit Graph
499 Commits
Author SHA1 Message Date
naibaandcloudcode 7b54a2d5ea 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 1e0f479bb5 chore(frontend-templates): bump admin-frontend to v2.0.8 2026-05-25 11:42:39 +00:00
naiba 3619e5551a fix(server-transfer): break loader sort ties by transferID
NewServerTransferClass merged Verified and acked-rollback rows and sorted
them by AckedAt only. On Windows time.Now() granularity is ~15.6ms, so
MarkVerified and an immediately-following MarkRevertDelivered routinely
share a timestamp. The stable sort then left the Verified candidate
ahead of the rollback that is actually on disk and the agent was locked
out on the next restart. Add transferID as a deterministic tiebreaker so
the later rotation always wins.
2026-05-25 10:36:43 +00:00
naiba e816e94fca feat: server transfer rotation 2026-05-25 10:17:34 +00:00
naibaandnaiba/CloudCode 02129f16fb fix(rpc): authorize agent task results
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-21 02:02:02 +00:00
naibaandnaiba/CloudCode 8add559ec8 fix(rpc): bind io streams to target agents
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-21 02:01:54 +00:00
naibaandnaiba/CloudCode fa31ba402e fix(rpc): allow global agent secret across server owners
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-19 01:58:53 +00:00
naibaandnaiba/CloudCode ee01a174fb fix(rpc): verify gRPC client UUID belongs to the agent secret owner
Auth.Check resolved client_uuid → server.ID via UUIDToID without
checking that the resolved server's UserID matched the user that the
secret was bound to. An agent presenting one user's secret could
target a different user's server UUID and impersonate it — poisoning
monitoring state, triggering alerts, or quietly receiving tasks the
real owner expected.

Add authorizeAgentForUUID: if the UUID is unknown we still allow new
registration bound to the secret owner; if the UUID is known but
points to someone else's server we reject. The rejection message
"client UUID does not belong to the agent secret owner" also helps
operators trace which user's secret has leaked.

Note: this changes runtime behaviour after batch-move/server — the
new owner must reconfigure agents with their own secret. That is the
correct contract; the previous behaviour was a cross-user reporting
bug.

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-18 15:17:37 +00:00
naibaandnaiba/CloudCode 26cf9b3fa6 fix(rpc): enforce magic ff05ff05 on IOStream init
The inline magic check expressed the *invalid* form as
\`byte0 != 0xff && byte1 != 0x05 && byte2 != 0xff && byte3 == 0x05\`,
relying on && to detect a four-byte mismatch. Because && short-circuits,
any payload whose byte0 happened to be 0xff was treated as a valid magic
even if the remaining bytes did not match — almost every random payload
slipped through and only the stream-UUID layer above stood between a
caller with a valid agent secret and a live IOStream session.

Extract the check into isValidIOStreamMagic stated positively (all four
bytes must match) so short-circuit reasoning cannot reintroduce the bug.

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-18 15:17:18 +00:00
naibaandnaiba/CloudCode 6661d6a7fc fix(rpc): bind io_stream sessions to creator to prevent terminal/fm hijack
createTerminal and createFM correctly check server ownership before
issuing a stream UUID, but terminalStream and fmStream only verified
that the UUID existed. Any authenticated user holding a valid stream
UUID could attach to it, gaining the original creator's live shell or
file-manager session — and the UUID is exposed via URL path (referer
leaks, access logs, browser history, frontend error reporters).

Bind the creator user ID into ioStreamContext at CreateStream time,
expose StreamOwnership and IsStreamAuthorizedForUser, and check
ownership in terminalStream/fmStream before the WebSocket upgrade so a
rejected attempt does not tear down the legitimate stream via defer.

NAT streams are also routed through CreateStream(_, 0); they are not
reachable from /ws/terminal or /ws/file so a sentinel user ID is fine.

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-18 15:16:40 +00:00
naibaandnaiba/CloudCode 9f21db2dc6 chore: bump admin frontend to v2.0.7
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-17 10:24:19 +08:00
naibaandnaiba/CloudCode c0e2470a9d test: cover multi-user permission boundaries
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-17 10:24:19 +08:00
naibaandnaiba/CloudCode d7526351cf fix(cron): restrict task delivery by owner
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-17 10:24:19 +08:00
uubulb 85b0dd2992 fix(OnUserDelete): only delete current iterated user from db 2026-05-09 12:38:39 +08:00
naiba 50dc8e6603 chore: upgrade frontend 2026-04-05 10:00:11 +08:00
naibaandnaiba/CloudCode 9acffc11f6 chore: bump Go to 1.26, update dependencies and frontend templates
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-03-20 11:23:03 +00:00
naiba 589563e744 chore: upgrade frontend 2026-03-01 11:50:56 +08:00
naiba bef07c400c chore: bump admin-frontend to v2.0.4, nezha-dash-v1 to v2.0.1 2026-02-19 06:34:02 +00:00
e61772e858 feat(v2.0.0): tsdb (#1162)
* feat: tsdb

* fix(ci): remove --parseGoList=false from swag init to fix dependency resolution

* fix(ci): fix swag init directory and temporary remove s390x support due to cgo issues

* fix(ci): fix swag init output directory to cmd/dashboard/docs

* fix(ci): set GOTOOLCHAIN=auto for gosec

* feat: add system storage maintenance for SQLite and TSDB

* shit

* feat: add s390x support and improve service monitoring

* ci: upgrade goreleaser-cross image to v1.25

* ci: add libzstd-dev:s390x for cross-compilation

* ci: build libzstd for s390x from source

* ci: add libzstd_linux_s390x.go for gozstd linking

* ci: use vendor mode for s390x gozstd build

* ci: clone zstd source for s390x build

* refactor(tsdb): rename MaxDiskUsageGB to MinFreeDiskSpaceGB and optimize queries

- Rename config to accurately reflect VictoriaMetrics behavior: minimum free disk space threshold
- Add QueryServiceHistoryByServerID for batch query optimization
- Fix hasStatus to avoid false status counting when only delay data exists
- Fix service aggregation boundary: use successCount*2 >= count
- Fix serviceID parsing with strconv.ParseUint error handling
- Add TagFiltersCacheSize for better query performance

* feat(api): add server metrics endpoint and simplify service history response

- Add /server/:id/metrics API for querying TSDB server metrics
- Simplify getServiceHistory by removing redundant data conversion
- Change AvgDelay type from float32 to float64
- Remove generated swagger docs (to be regenerated)
- Update TSDB query, writer and tests

* chore: 临时禁用不支持前端

* ci: cache zstd build for s390x to speed up CI

* fix(tsdb): fix race conditions, data correctness and optimize performance

- Fix TOCTOU race between IsClosed() and write/query by holding RLock
- Fix delay=0 excluded from stats by using hasDelay flag instead of value > 0
- Fix fmt.Sscanf -> strconv.ParseUint for server_id parsing with error logging
- Fix buffer unbounded growth by flushing inside lock when over maxSize
- Split makeMetricRow into makeServerMetricRow/makeServiceMetricRow
- Extract InitGlobalSettings() from Open() for VictoriaMetrics globals
- Remove redundant instance/GetInstance/SetInstance singleton
- Add error logging for silently skipped block decode errors
- Optimize WriteBatch* to build all rows in single write call
- Optimize downsample to use linear scan instead of map for sorted data
- Optimize query slice reuse across block iterations

* 服务添加DisplayIndex (#1166)

* 服务添加DisplayIndex

* 根据ai建议修改

---------

Co-authored-by: huYang <306061454@qq.com>

* fix(tsdb): restore SQLite fallback and monthly status reload on restart

- Restore ServiceHistory model and SQLite write fallback when TSDB is disabled
- Reload monthlyStatus (30-day) and serviceStatusToday from TSDB/SQLite on startup
- Add SQLite fallback query for /service/:id/history and /server/:id/service
- Remove breaking GET /service/:id endpoint, keep /service/:id/history only
- Add QueryServiceDailyStats to TSDB for per-day aggregation
- Add tests for monthly status and today stats loading from both TSDB and SQLite
- Migrate ServiceHistory table only when TSDB is disabled

* ci: exclude false-positive gosec rules G117, G703, G704

* feat(api): expose tsdb_enabled in setting response

* ci: restore G115 exclusion accidentally dropped in previous commit

* fix: update version numbers for OfficialAdmin and Official templates

* chore: upgrade frontend

* chore: upgrade frontend

---------

Co-authored-by: 胡说丷刂 <34758853+laosan-xx@users.noreply.github.com>
Co-authored-by: huYang <306061454@qq.com>
2026-02-15 13:13:33 +08:00
naiba 4c4758207d chore: upgrade frontend 2026-01-10 20:23:28 +08:00
naiba 439192b4c8 chore: upgrade frontend 2026-01-10 17:38:15 +08:00
naiba 554db7cd64 chore: upgrade frontend 2026-01-01 10:56:52 +08:00
naiba 1db4fe4679 chore: upgrade frontend 2025-10-09 18:32:30 +08:00
naiba a9fd269ea9 chore: upgrade frontend 2025-10-09 09:50:55 +08:00
naiba e1e0a812a6 chore: upgrade frontend 2025-10-09 09:38:01 +08:00
naiba f16f0892bc 💩 f*ck react
react 纯傻逼,js ts 就是纯傻逼,浪费人生
2025-10-02 17:19:26 +08:00
naiba fece19a940 feat: upgrade frontend 2025-10-02 15:30:21 +08:00
naiba 085ac7540f feat: upgrade frontend 2025-10-02 14:28:57 +08:00
UUBulb b6fed87d61 fix: member-created services shouldn't be applied to admin resources (#1113) 2025-08-28 22:37:44 +08:00
naiba 61b8411d06 chore: upgrade frontend 2025-08-23 21:14:02 +08:00
naiba bce7fdd547 feat: 批量转移服务器给其他用户 2025-06-16 23:46:36 +08:00
naiba 3332504584 chore: upgrade frontend 2025-05-04 11:35:14 +08:00
UUBulb 4871211f93 chore: cleanup some code (#1069)
* chore

* modernize loop

* ddns: simpify Provider struct
2025-04-26 18:28:21 +08:00
naiba 65f728e5b1 feat: upgrade frontend 2025-04-25 23:03:14 +08:00
naiba 0afdfc70d1 feat: upgrade frontend 2025-04-13 18:42:24 +08:00
naiba 6c42fdcf92 feat: upgrade frontend 2025-04-13 12:28:28 +08:00
UUBulb 91cb5e903f i18n: replace gettext implementation (#1056) 2025-04-13 12:26:03 +08:00
naiba 663688ea94 feat: upgrade frontend 2025-03-31 19:53:19 +08:00
naiba b69eac4310 refactor: clean code 2025-03-31 19:52:23 +08:00
UUBulb 67c129635e update ddns on server update (#1050) 2025-03-31 19:41:04 +08:00
naiba 107808249d fix(nat): nat records not loaded 2025-03-29 13:11:56 +08:00
naiba 13384c8a64 chore: upgrade frontend 2025-03-29 11:29:58 +08:00
naiba 697d90562e feat: upgrade frontend 2025-03-27 19:18:14 +08:00
UUBulb ec44dbbd9b fix search by id (#1047)
* fix search by id

* make SearchByID Public
2025-03-27 19:17:00 +08:00
naiba 314eadafc6 chore: upgrade frontend 2025-03-26 20:23:59 +08:00
naiba 2fc1046668 chore: upgrade frontend 2025-03-25 22:51:11 +08:00
UUBulb fdbf7bfba9 add tests for config & iostream (#1045)
* add tests for config & iostream

* chore
2025-03-25 22:44:07 +08:00
naiba 954939e99d feat: upgrade frontend 2025-03-22 22:44:25 +08:00
naiba 95dd5271b9 chore: upgrade frontend 2025-03-20 23:49:25 +08:00
naiba 6f1f6a95ee chore: upgrade frontend 2025-03-19 22:23:38 +08:00