init
Some checks failed
release-tag / release-image (push) Failing after 1m28s

This commit is contained in:
2025-09-24 10:32:22 +02:00
parent b851b57e28
commit dc3abf661f
17 changed files with 1008 additions and 0 deletions

20
internal/security/http.go Normal file
View File

@@ -0,0 +1,20 @@
package security
import "net/http"
func MaxBody(n int64, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, n)
next.ServeHTTP(w, r)
})
}
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("Referrer-Policy", "no-referrer")
w.Header().Set("Content-Security-Policy", "default-src 'self'")
next.ServeHTTP(w, r)
})
}