vm-bench/frontend/templates/base.html
Claus Lohmar 63659e4f93 feat: session GUID isolation for multi-user support
Each browser gets a UUID stored in localStorage, set as a cookie,
and attached to every API call. Files go to session-specific dirs:

  /mnt/converter/in/{guid}/    — uploads, downloads, SCP pulls
  /mnt/converter/out/{guid}/   — converted QCOW2s

Changes:
- base.html: generates UUID via crypto.randomUUID(), stores in
  localStorage + cookie, exposes as window.VM_BENCH_SID
- Frontend: all endpoints accept session_id, _staging() helper
  creates session-aware paths on demand
- JavaScript: session_id appended to all FormData, set as
  X-Session-ID header on raw uploads
- Backend models: JobSubmissionRequest.session_id field added
- Provisioner: _staging_in/_staging_out helpers, source path
  resolution uses session-aware directory
- Converter: extract_if_needed skips re-extraction if dir exists
2026-07-23 09:32:16 +00:00

42 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VM Bench — Proxmox Image Converter</title>
<link rel="stylesheet" href="/static/proxmox.css?v=5">
<script>
// Session GUID — one per browser, persists across tabs/refreshes
(function() {
var sid = localStorage.getItem('vm-bench-sid');
if (!sid) {
sid = crypto.randomUUID ? crypto.randomUUID() :
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c=='x'?r:(r&0x3|0x8);
return v.toString(16);
});
localStorage.setItem('vm-bench-sid', sid);
}
document.cookie = 'vm_bench_sid=' + sid + ';path=/;SameSite=Lax';
window.VM_BENCH_SID = sid;
})();
</script>
</head>
<body>
<header class="pve-header">
<div class="pve-logo">VM Bench</div>
<div class="pve-sub">Proxmox Image Conversion</div>
</header>
<div class="pve-container">
{% block content %}{% endblock %}
</div>
<footer class="pve-footer">
<span>vm-bench frontend</span>
<span>Backend: {{ backend_url or "10.2.0.2:9000" }}</span>
</footer>
</body>
</html>