Commit Graph
41 Commits
Author SHA1 Message Date
naibaandcloudcode e8dabf5bc6 feat(auth): add PAT auth, scoped REST/MCP access, CSRF, and tenant isolation
Introduce Personal Access Tokens (nzp_*) as a stateless auth path alongside
JWT, gated per-endpoint by a scope middleware (nezha:{resource}:{verb}) with
fail-closed empty-scope defaults and a server-id whitelist. Self-management
endpoints (profile, api-tokens, oauth2 bind, refresh-token) explicitly reject
PATs to block privilege-escalation chains. A revoke registry tears down active
long-lived connections (terminal, fm, ws, transfer, mcp) the moment a PAT is
deleted, with a tombstone closing the revoke->register race.

Add an MCP endpoint that proxies tool calls (exec, fs read/write/delete,
transfer) to agents over gRPC, guarded by origin/DNS-rebinding checks, a
per-token rate limiter, audit logging, and a kill switch. Serialize all
sends through the IOStream wrapper to honour grpc-go's concurrency contract.

Add CSRF double-submit protection on unsafe cookie-authenticated methods,
exempting authenticated PAT requests by context identity (not a forgeable
Authorization header). Apply visibility/whitelist filtering consistently
across list, get-by-id, and mutate paths to enforce tenant isolation.

Migrate legacy mcp:* scopes: rewrite read/exec to nezha:* equivalents and
drop dangerous write/delete/wildcard grants.

Co-authored-by: cloudcode <cloudcode@users.noreply.github.com>
2026-05-30 15:56:44 +00:00
UUBulb f110ff761a fix: ignore the duration of out-of-bound rules (#1019) 2025-03-07 20:23:18 +08:00
naiba a723893a44 fix: range data point 2025-03-02 16:57:24 +08:00
UUBulb a26337acb2 fix service (#1015) 2025-03-02 16:36:57 +08:00
UUBulb af55fae652 improve check for offline rules (#1013)
* improve check for offline rules

* bug fixes

* update dependencies

* fix error wrap

* fix offline check

* improve readability
2025-03-02 15:37:21 +08:00
UUBulb 043d6c4097 feat: update to go1.24 & support listening https (#1002)
* feat: support listening https

* refactor

* modernize

* support snake case in config

* more precise control of config fields

* update goreleaser config

* remove kubeyaml

* fix: expose agent_secret

* chore
2025-02-28 22:02:54 +08:00
UUBulb ff4fd31ec4 small improvements (#958)
* small improvements

* fix: return empty iterator if no json present

* use time.Tick

* changes
2025-01-19 21:22:00 +08:00
naiba 0364632ebc fix: 修复因采样不足导致的告警 2024-12-28 00:29:58 +08:00
naiba 42ef1bcffd improve: check performance 2024-12-28 00:07:07 +08:00
naiba 223f72ef68 fix: rule check 2024-12-27 00:07:44 +08:00
naiba 39b82222dd chore: fix index bug & upgrade frontend 2024-12-26 23:52:44 +08:00
UUBulb d70cfe9ee9 bug fixes (#918)
* bug fixes

* fix for backward compatibility

* fix init

* cleanup

* possible fix

* optimize permission check

* Revert "possible fix"

This reverts commit 003f1bbb2aa368aade6702e6019922b7f4871a39.
2024-12-26 23:38:40 +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
naiba 7d689862d8 fix: rule snapshot 2024-12-19 23:21:15 +08:00
naiba a7e4fe0909 rename repo 2024-11-28 19:38:54 +08:00
UUBulb 5c1599c88c fix struct tags (#7) 2024-11-16 20:57:03 +08:00
UUBulb 8bfe70d519 add cron, nat api & refactor alert rule (#459)
* add cron api & refactor alert rule

* add nat api

* fix swagger

* remove unnecessary steps
2024-10-26 23:57:47 +08:00
UUBulb 785b4dce37 add alert api (#458) 2024-10-26 08:16:57 +08:00
naiba 868c242eb3 refactor: rename monitor -> service 2024-10-25 00:13:45 +08:00
UUBulb 28b606ef7b implement notification group (#450)
* implement notification group

* some fixes

* fix sql

* add listNotification

* retrieve notification from map

* create notification_group_notification if non-exist

* NotificationIDToGroup -> NotificationIDToGroups

* clean
2024-10-23 21:55:12 +08:00
Mmx 9df97e2bdb Fix Coroutine Leaks and Proxy Handling in http.Client (#304)
* fix: builtin variable conflict

* feat: add pkg/utils/http HttpClientSkipTlsVerify HttpClient

* fix: realtime create http Transport

* fix: http keepalive connection may not reusable

* feat: allow http request use proxy from environment
2023-12-05 23:22:25 +08:00
Akkia c114083a44 为新增字段提供默认值 2022-09-14 12:16:24 +08:00
Akkia c900941f3b feat: 报警规则支持绑定触发任务 2022-09-14 11:14:23 +08:00
Akkia 8ae2de3882 feat: 触发报警后的通知支持仅发送一次 2022-09-13 04:01:08 +08:00
Akkia a7261b1510 WIP: 补全各模块的通知分组设置 2022-04-15 03:13:53 +08:00
Akkia 9776cf6182 添加代码注释+修正一个typo 2022-04-11 22:51:02 +08:00
naiba a90c0400d9 ️ 使用 json-iterator 替换 encoding/json 进行一些序列化/反序列化操作 2022-03-18 23:13:22 +08:00
naiba 62e1e00189 💄 优化循环流量展示 2021-11-11 09:40:10 +08:00
naiba 24bfeb94ac 展示月流量使用情况 2021-11-06 16:00:08 +08:00
naiba 3701f0c166 🚸 使用服务器端时间判断机器离线 2021-07-16 11:14:07 +08:00
naiba f7e9ea72dd 任意时间区间(月流量)统计,无视重启~ 2021-07-14 23:53:37 +08:00
naiba 5f46036f0e 优化 agent 信息上报与 ARM 安装面板的错误提示 2021-06-30 18:15:53 +08:00
naiba a9c7281af8 优化忽略规则配置和 Agent 获取 IP 2021-06-21 21:30:42 +08:00
naiba 8062e346d5 接入 Gitee 登录,v0.4.11 之前的用户需要更新配置文件 2021-03-02 23:08:40 +08:00
naiba 27fcfbf76a 🚸 release: v0.2.1 2021-01-16 14:11:51 +08:00
naiba 8cc5d1c32b 💥 v2.0 必须更新面板,新增服务监控 2021-01-16 00:45:49 +08:00
naiba de9d781326 🐛 fix: 旧采样点清理及报警策略优化 2021-01-06 21:20:02 +08:00
naiba 10d7cdf106 🐛 fix: divide by zero 2021-01-06 12:46:13 +08:00
naiba d81688a6d7 🐛 fix(alert): 多规则同时满足 2020-12-21 22:51:23 +08:00
naiba e1a0c3a7c3 🍻 报警通知上线 2020-12-20 12:18:27 +08:00
naiba 62fdf18fb7 up(notification): 添加修改删除通知、报警规则 2020-12-19 23:11:16 +08:00