fix(security): replace X-Frame-Options DENY with CSP frame-ancestors allowlist for HF Spaces embed
Browse files
docsifer/api/middleware.py
CHANGED
|
@@ -16,7 +16,13 @@ ASGICall = Callable[[Request], Awaitable[Response]]
|
|
| 16 |
REQUEST_ID_HEADER = "X-Request-ID"
|
| 17 |
_SECURITY_HEADERS = {
|
| 18 |
"X-Content-Type-Options": "nosniff",
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
"Referrer-Policy": "no-referrer",
|
| 21 |
"X-XSS-Protection": "0",
|
| 22 |
}
|
|
|
|
| 16 |
REQUEST_ID_HEADER = "X-Request-ID"
|
| 17 |
_SECURITY_HEADERS = {
|
| 18 |
"X-Content-Type-Options": "nosniff",
|
| 19 |
+
# Allow huggingface.co to embed the Space in its hub iframe while still
|
| 20 |
+
# blocking arbitrary third-party framing. ``frame-ancestors`` supersedes
|
| 21 |
+
# the legacy ``X-Frame-Options`` header (which has no allowlist mode).
|
| 22 |
+
"Content-Security-Policy": (
|
| 23 |
+
"frame-ancestors 'self' https://huggingface.co https://*.huggingface.co "
|
| 24 |
+
"https://*.hf.space"
|
| 25 |
+
),
|
| 26 |
"Referrer-Policy": "no-referrer",
|
| 27 |
"X-XSS-Protection": "0",
|
| 28 |
}
|