Use per-response random CSP nonce in Garage dashboard
This commit is contained in:
1 parent
f642a50048
commit
12cf1b136c
1 file changed
+6
-5
@@ -24,8 +24,6 @@ namespace NexVerse.Server.Api
|
||||
{
|
||||
response.AddHeader("Cache-Control", "no-store");
|
||||
response.AddHeader("X-Content-Type-Options", "nosniff");
|
||||
response.AddHeader("Content-Security-Policy",
|
||||
"default-src 'none'; script-src 'nonce-oglgarage'; style-src 'nonce-oglgarage'; connect-src 'self'; img-src 'none'; base-uri 'none'; frame-ancestors 'none'");
|
||||
if (request == null || !string.Equals(request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
response.StatusCode = 405;
|
||||
@@ -37,8 +35,11 @@ namespace NexVerse.Server.Api
|
||||
response.StatusCode = 503;
|
||||
return;
|
||||
}
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
response.AddHeader("Content-Security-Policy",
|
||||
"default-src 'none'; script-src 'nonce-" + nonce + "'; style-src 'nonce-" + nonce + "'; connect-src 'self'; img-src 'none'; base-uri 'none'; frame-ancestors 'none'");
|
||||
response.ContentType = "text/html; charset=utf-8";
|
||||
response.RawBuffer = Encoding.UTF8.GetBytes(Html);
|
||||
response.RawBuffer = Encoding.UTF8.GetBytes(Html.Replace("oglgarage-nonce-placeholder", nonce));
|
||||
response.StatusCode = 200;
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ namespace NexVerse.Server.Api
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>OpenGenesisLINK · Garage Storage</title>
|
||||
<style nonce="oglgarage">
|
||||
<style nonce="oglgarage-nonce-placeholder">
|
||||
:root{color-scheme:dark;font-family:system-ui,sans-serif;background:#0b1220;color:#e8eef8}
|
||||
*{box-sizing:border-box}body{margin:0;padding:clamp(16px,4vw,48px)}
|
||||
main{max-width:1060px;margin:auto}header{display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap}
|
||||
@@ -75,7 +76,7 @@ small{color:#aebed5}a{color:#9ec7ff}footer{margin-top:24px}
|
||||
<article style="margin-top:16px"><div class="label">Logische Auslastung</div><div class="value" id="percent">–</div><div class="progress" role="progressbar" aria-label="Speicherbelegung" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" id="progress"><div id="bar"></div></div></article>
|
||||
<footer><small id="updated">Noch keine Messung</small> · <a href="/api/v1/public/storage/garage">JSON-Schnittstelle</a></footer>
|
||||
</main>
|
||||
<script nonce="oglgarage">
|
||||
<script nonce="oglgarage-nonce-placeholder">
|
||||
const $=id=>document.getElementById(id);
|
||||
const bytes=n=>new Intl.NumberFormat('de-DE',{maximumFractionDigits:2}).format(n/1e9)+' GB';
|
||||
async function refresh(){
|
||||
|
||||
Reference in new issue
Block a user