Sandbox artifact rendering via iframe + CSP
Splits /p/{slug} into a trusted wrapper (HTML with a sandboxed iframe)
and /p/{slug}/raw (the artifact itself, served with Content-Security-Policy:
sandbox). Artifact JS now runs in an opaque origin and can't read admin
cookies or make same-origin credentialed requests to /a/* or /api/*.
Password gating is enforced on both routes so /raw can't be used to bypass
the unlock flow.
This commit is contained in:
18
internal/server/templates/artifact_wrapper.html
Normal file
18
internal/server/templates/artifact_wrapper.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>artifact</title>
|
||||
<style>
|
||||
html, body { margin: 0; padding: 0; height: 100%; background: #fff; }
|
||||
iframe { display: block; width: 100%; height: 100vh; border: 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe sandbox="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals"
|
||||
src="/p/{{.Slug}}/raw"
|
||||
referrerpolicy="no-referrer"
|
||||
title="artifact"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user