mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 17:50:12 +00:00
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>
48 lines
2.3 KiB
Go
48 lines
2.3 KiB
Go
package model
|
|
|
|
type SettingForm struct {
|
|
DNSServers string `json:"dns_servers,omitempty" validate:"optional"`
|
|
IgnoredIPNotification string `json:"ignored_ip_notification,omitempty" validate:"optional"`
|
|
IPChangeNotificationGroupID uint64 `json:"ip_change_notification_group_id,omitempty"` // IP变更提醒的通知组
|
|
Cover uint8 `json:"cover,omitempty"`
|
|
SiteName string `json:"site_name,omitempty" minLength:"1"`
|
|
Language string `json:"language,omitempty" minLength:"2"`
|
|
InstallHost string `json:"install_host,omitempty" validate:"optional"`
|
|
CustomCode string `json:"custom_code,omitempty" validate:"optional"`
|
|
CustomCodeDashboard string `json:"custom_code_dashboard,omitempty" validate:"optional"`
|
|
WebRealIPHeader string `json:"web_real_ip_header,omitempty" validate:"optional"` // 前端真实IP
|
|
AgentRealIPHeader string `json:"agent_real_ip_header,omitempty" validate:"optional"` // Agent真实IP
|
|
UserTemplate string `json:"user_template,omitempty" validate:"optional"`
|
|
|
|
AgentTLS bool `json:"tls,omitempty" validate:"optional"`
|
|
EnableIPChangeNotification bool `json:"enable_ip_change_notification,omitempty" validate:"optional"`
|
|
EnablePlainIPInNotification bool `json:"enable_plain_ip_in_notification,omitempty" validate:"optional"`
|
|
EnableMCP *bool `json:"enable_mcp,omitempty" validate:"optional"`
|
|
}
|
|
|
|
type Setting struct {
|
|
ConfigForGuests
|
|
ConfigDashboard
|
|
|
|
IgnoredIPNotificationServerIDs map[uint64]bool `json:"ignored_ip_notification_server_ids,omitempty"`
|
|
Oauth2Providers []string `json:"oauth2_providers,omitempty"`
|
|
}
|
|
|
|
type FrontendTemplate struct {
|
|
Path string `json:"path,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Repository string `json:"repository,omitempty"`
|
|
Author string `json:"author,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
IsAdmin bool `json:"is_admin,omitempty"`
|
|
IsOfficial bool `json:"is_official,omitempty"`
|
|
}
|
|
|
|
type SettingResponse struct {
|
|
Config Setting `json:"config"`
|
|
|
|
Version string `json:"version,omitempty"`
|
|
FrontendTemplates []FrontendTemplate `json:"frontend_templates,omitempty"`
|
|
TSDBEnabled bool `json:"tsdb_enabled"`
|
|
}
|