security(launcher): add HTTP security headers middleware

Add SecurityHeaders middleware setting X-Content-Type-Options,
X-Frame-Options, and Content-Security-Policy on all responses
to mitigate MIME sniffing, clickjacking, and content injection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
admin-mf 2026-03-06 00:05:24 -06:00
parent 977daab6aa
commit 4db187ab27
2 changed files with 11 additions and 1 deletions

View file

@ -197,3 +197,13 @@ func RegisterAuthAPI(mux *http.ServeMux, absPath string) {
// GET /auth/callback — OAuth browser callback for Google Antigravity // GET /auth/callback — OAuth browser callback for Google Antigravity
mux.HandleFunc("GET /auth/callback", handleOAuthCallback) mux.HandleFunc("GET /auth/callback", handleOAuthCallback)
} }
// SecurityHeaders wraps an http.Handler to add standard security headers.
func SecurityHeaders(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("X-Frame-Options", "DENY")
w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'")
next.ServeHTTP(w, r)
})
}

View file

@ -105,7 +105,7 @@ func main() {
} }
}() }()
if err := http.ListenAndServe(addr, mux); err != nil { if err := http.ListenAndServe(addr, server.SecurityHeaders(mux)); err != nil {
log.Fatalf("Server failed: %v", err) log.Fatalf("Server failed: %v", err)
} }
} }