mirror of
https://codeberg.org/gothub/gothub
synced 2024-12-06 19:16:24 +01:00
Massive security improvement: Add security headers (fixes #51)
Signed-off-by: Odyssey <hi@odyssey346.dev>
This commit is contained in:
@@ -80,6 +80,18 @@ func Serve() {
|
||||
MaxAge: 31536000,
|
||||
}
|
||||
|
||||
// add global headers
|
||||
app.Use(func(c *fiber.Ctx) error {
|
||||
c.Set("X-Frame-Options", "SAMEORIGIN")
|
||||
c.Set("X-XSS-Protection", "1; mode=block")
|
||||
c.Set("X-Content-Type-Options", "nosniff")
|
||||
c.Set("Referrer-Policy", "no-referrer")
|
||||
c.Set("Content-Security-Policy", "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval';")
|
||||
c.Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload")
|
||||
|
||||
return c.Next()
|
||||
})
|
||||
|
||||
app.Get("/", pages.HandleIndex)
|
||||
app.Static("/css", "./public/css", staticConfig)
|
||||
app.Static("/fonts", "./public/fonts", staticConfig)
|
||||
|
||||
Reference in New Issue
Block a user