feat(security): enable Content-Security-Plolicy #263
This commit was merged in pull request #265.
This commit is contained in:
@@ -35,5 +35,5 @@ func GetHandler(d *sql.DB, serverSettings *types.ServerSettings) http.Handler {
|
||||
|
||||
authHandler.handle(router)
|
||||
|
||||
return middleware.Logging(middleware.EnableCors(serverSettings, router))
|
||||
return middleware.Logging(middleware.ContentSecurityPolicy(middleware.EnableCors(serverSettings, router)))
|
||||
}
|
||||
|
||||
11
middleware/content_security_policiy.go
Normal file
11
middleware/content_security_policiy.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package middleware
|
||||
|
||||
import "net/http"
|
||||
|
||||
func ContentSecurityPolicy(next http.Handler) http.Handler {
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Security-Policy", "default-src 'self'")
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user