mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
18 lines
490 B
Go
18 lines
490 B
Go
|
package mox
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
// Set some http headers that should prevent potential abuse. Better safe than sorry.
|
||
|
func SafeHeaders(fn http.Handler) http.Handler {
|
||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||
|
h := w.Header()
|
||
|
h.Set("X-Frame-Options", "deny")
|
||
|
h.Set("X-Content-Type-Options", "nosniff")
|
||
|
h.Set("Content-Security-Policy", "default-src 'self' 'unsafe-inline' data:")
|
||
|
h.Set("Referrer-Policy", "same-origin")
|
||
|
fn.ServeHTTP(w, r)
|
||
|
})
|
||
|
}
|