Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions astrbot/dashboard/routes/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,21 @@ def _apply_plugin_page_security_headers(response: QuartResponse) -> QuartRespons
response.headers["Cache-Control"] = "no-store"
response.headers["Referrer-Policy"] = "no-referrer"
response.headers["X-Content-Type-Options"] = "nosniff"
response.headers["X-Frame-Options"] = "SAMEORIGIN"
response.headers["Cross-Origin-Resource-Policy"] = "cross-origin"
# Sandboxed iframes without allow-same-origin load ES modules with Origin: null.
# CORS read access is allowed here; JWT/asset_token still protects the assets.
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Content-Security-Policy"] = (
"frame-ancestors 'self'; object-src 'none'; base-uri 'self'"
)

# When running under the AstrBot Launcher the dashboard is embedded in a
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
# cross-origin iframe (the Tauri webview). Since frame-ancestors and
# X-Frame-Options inspect the *entire* ancestor chain, enforcing them here
# would block plugin pages from loading inside the nested iframe.
csp = "object-src 'none'; base-uri 'self'"
if os.environ.get("ASTRBOT_LAUNCHER") not in ("1", "true"):
response.headers["X-Frame-Options"] = "SAMEORIGIN"
csp = f"frame-ancestors 'self'; {csp}"
response.headers["Content-Security-Policy"] = csp
Comment thread
lxfight marked this conversation as resolved.

return response

async def _serve_plugin_page_html_asset(
Expand Down
Loading