Merge pull request #155 from Molecule-AI/fix/issue-151-register-security-headers

fix(security): #151 — register SecurityHeaders middleware
This commit is contained in:
Hongming Wang 2026-04-15 03:51:02 -07:00 committed by GitHub
commit 3d6ad16a8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,6 +59,14 @@ func Setup(hub *ws.Hub, broadcaster *events.Broadcaster, prov *provisioner.Provi
// rejected requests still land on the 4xx counter.
r.Use(middleware.TenantGuard())
// Security headers (#151) — sets X-Content-Type-Options, X-Frame-Options,
// Referrer-Policy, Content-Security-Policy, Permissions-Policy, HSTS on
// every response. Tests in securityheaders_test.go assert each header is
// present and that handler-set headers are not overridden. Registered
// last so a handler can still opt out by setting its own header before
// c.Next() returns.
r.Use(middleware.SecurityHeaders())
// Health
r.GET("/health", func(c *gin.Context) {
c.JSON(200, gin.H{"status": "ok"})