mirror of
https://github.com/owncast/owncast.git
synced 2024-12-18 07:12:33 +03:00
Merge pull request from GHSA-2hfj-cxw7-g45p
This commit is contained in:
parent
663a7b5fe1
commit
7278ce8f26
3 changed files with 21 additions and 10 deletions
|
@ -68,8 +68,8 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Set a cache control max-age header
|
// Set a cache control max-age header
|
||||||
middleware.SetCachingHeaders(w, r)
|
middleware.SetCachingHeaders(w, r)
|
||||||
|
|
||||||
// Opt-out of Google FLoC
|
// Set our global HTTP headers
|
||||||
middleware.DisableFloc(w)
|
middleware.SetHeaders(w)
|
||||||
|
|
||||||
http.ServeFile(w, r, path.Join(config.WebRoot, r.URL.Path))
|
http.ServeFile(w, r, path.Join(config.WebRoot, r.URL.Path))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package middleware
|
|
||||||
|
|
||||||
import "net/http"
|
|
||||||
|
|
||||||
// DisableFloc will tell Google to not use this response in their FLoC tracking.
|
|
||||||
func DisableFloc(w http.ResponseWriter) {
|
|
||||||
w.Header().Set("Permissions-Policy", "interest-cohort=()")
|
|
||||||
}
|
|
19
router/middleware/headers.go
Normal file
19
router/middleware/headers.go
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetHeaders will set our global headers for web resources.
|
||||||
|
func SetHeaders(w http.ResponseWriter) {
|
||||||
|
// Tell Google to not use this response in their FLoC tracking.
|
||||||
|
w.Header().Set("Permissions-Policy", "interest-cohort=()")
|
||||||
|
|
||||||
|
// Content security policy
|
||||||
|
csp := []string{
|
||||||
|
"script-src 'self' 'sha256-2HPCfJIJHnY0NrRDPTOdC7AOSJIcQyNxzUuut3TsYRY='",
|
||||||
|
"worker-src 'self' blob:", // No single quotes around blob:
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Security-Policy", strings.Join(csp, "; "))
|
||||||
|
}
|
Loading…
Reference in a new issue