fix(canary): CSP allows challenges.cloudflare.com for Turnstile
Audit F10: script-src 'self' blocked the Turnstile bootstrap script (https://challenges.cloudflare.com/turnstile/v0/api.js) and its widget iframe. Added challenges.cloudflare.com to script-src, connect-src, and a new frame-src directive so the widget can render under prod CSP.
This commit is contained in:
parent
e78c33ae18
commit
4382ba5e17
|
|
@ -42,18 +42,19 @@ func SecurityHeaders(isProduction bool) func(http.Handler) http.Handler {
|
||||||
func buildCSP(isProduction bool) string {
|
func buildCSP(isProduction bool) string {
|
||||||
directives := []string{
|
directives := []string{
|
||||||
"default-src 'self'",
|
"default-src 'self'",
|
||||||
"script-src 'self'",
|
"script-src 'self' https://challenges.cloudflare.com",
|
||||||
"style-src 'self' 'unsafe-inline'",
|
"style-src 'self' 'unsafe-inline'",
|
||||||
"img-src 'self' data: https:",
|
"img-src 'self' data: https:",
|
||||||
"font-src 'self'",
|
"font-src 'self'",
|
||||||
"connect-src 'self'",
|
"connect-src 'self' https://challenges.cloudflare.com",
|
||||||
|
"frame-src https://challenges.cloudflare.com",
|
||||||
"frame-ancestors 'none'",
|
"frame-ancestors 'none'",
|
||||||
"base-uri 'self'",
|
"base-uri 'self'",
|
||||||
"form-action 'self'",
|
"form-action 'self'",
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isProduction {
|
if !isProduction {
|
||||||
directives[1] = "script-src 'self' 'unsafe-inline' 'unsafe-eval'"
|
directives[1] = "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://challenges.cloudflare.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(directives, "; ")
|
return strings.Join(directives, "; ")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue