mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-04 12:41:50 +08:00
fix: remove application fingerprints from public responses
This commit is contained in:
1 parent
c0b558fa1e
commit
5203176364
9 files changed
+195
-20
No files matched your search
+11
-2
@@ -34,7 +34,7 @@ import (
|
||||
|
||||
// BuildVersion is the backend application version, injected from cmd/artex at
|
||||
// startup (which in turn gets it from -ldflags "-X main.version=<tag>").
|
||||
// Defaults to "dev" for local builds. Exposed to the frontend via GET /api/health.
|
||||
// Defaults to "dev" for local builds. Exposed via the authenticated GET /api/version.
|
||||
var BuildVersion = "dev"
|
||||
|
||||
// Server exposes the ARTEX backend over a JSON HTTP API for the shadcn/ui
|
||||
@@ -803,6 +803,7 @@ func (s *Server) Handler() http.Handler {
|
||||
mux.HandleFunc("PUT /api/settings/basic-auth", s.saveBasicAuthSettings)
|
||||
|
||||
mux.HandleFunc("GET /api/health", s.health)
|
||||
mux.HandleFunc("GET /api/version", s.version)
|
||||
mux.HandleFunc("GET /api/stats", s.stats)
|
||||
mux.HandleFunc("GET /api/system/metrics", s.systemMetrics)
|
||||
mux.HandleFunc("GET /api/logs", s.getLogs)
|
||||
@@ -1149,8 +1150,16 @@ func (s *Server) Handler() http.Handler {
|
||||
|
||||
// --- handlers ---
|
||||
|
||||
// health stays public for probes and must not expose application fingerprints.
|
||||
func (s *Server) health(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, 200, map[string]any{"ok": true, "service": "artex", "version": BuildVersion})
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
writeJSON(w, 200, map[string]any{"ok": true})
|
||||
}
|
||||
|
||||
// version is protected by the normal JWT middleware and optional Basic Auth gate.
|
||||
func (s *Server) version(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
writeJSON(w, 200, map[string]any{"version": BuildVersion})
|
||||
}
|
||||
|
||||
func (s *Server) stats(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in new issue
Block a user