Umbau broekr auf client-id
This commit is contained in:
1 parent
268e150f2b
commit
a95204b8d6
17 files changed
+649
-388
No files matched your search
@@ -19,6 +19,7 @@
|
||||
<table id="brokerStatusTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Client-ID</th>
|
||||
<th>Account-ID</th>
|
||||
<th>Account</th>
|
||||
<th>Rolle</th>
|
||||
@@ -26,7 +27,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="brokerStatusBody">
|
||||
<tr><td colspan="4">Lade...</td></tr>
|
||||
<tr><td colspan="5">Lade...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
+17
-29
@@ -29,38 +29,26 @@
|
||||
return clean ? base + '/' + clean : (base || '/');
|
||||
};
|
||||
|
||||
// Stabile ID pro Browser-Tab. Sie übersteht ein Neuladen und ordnet
|
||||
// die WebSocket-Sitzung ihrer Nachrichten-Queue beim Broker zu.
|
||||
(function initClientSessionId() {
|
||||
const key = 'cmbnet:client-session:' + (window.CMBNET_TENANT || '');
|
||||
let sessionId = null;
|
||||
// Jede Webview erhält beim Laden genau eine neue Client-ID. Sie wird
|
||||
// bewusst nicht in sessionStorage gespeichert: Ein Neuladen erzeugt
|
||||
// eine neue Webview und damit eine neue Broker-Verbindung.
|
||||
(function initClientId() {
|
||||
let clientId = null;
|
||||
|
||||
try {
|
||||
sessionId = window.sessionStorage.getItem(key);
|
||||
} catch (error) {
|
||||
// sessionStorage kann in privaten Kontexten gesperrt sein.
|
||||
if (window.crypto && typeof window.crypto.randomUUID === 'function') {
|
||||
clientId = window.crypto.randomUUID();
|
||||
} else if (window.crypto && typeof window.crypto.getRandomValues === 'function') {
|
||||
const bytes = new Uint8Array(16);
|
||||
window.crypto.getRandomValues(bytes);
|
||||
clientId = Array.from(bytes, value => value.toString(16).padStart(2, '0')).join('');
|
||||
} else {
|
||||
clientId = 'client-' + Date.now().toString(36) + '-' +
|
||||
Math.random().toString(36).slice(2, 12);
|
||||
}
|
||||
|
||||
if (!sessionId) {
|
||||
if (window.crypto && typeof window.crypto.randomUUID === 'function') {
|
||||
sessionId = window.crypto.randomUUID();
|
||||
} else if (window.crypto && typeof window.crypto.getRandomValues === 'function') {
|
||||
const bytes = new Uint8Array(16);
|
||||
window.crypto.getRandomValues(bytes);
|
||||
sessionId = Array.from(bytes, value => value.toString(16).padStart(2, '0')).join('');
|
||||
} else {
|
||||
sessionId = 'sess-' + Date.now().toString(36) + '-' +
|
||||
Math.random().toString(36).slice(2, 12);
|
||||
}
|
||||
|
||||
try {
|
||||
window.sessionStorage.setItem(key, sessionId);
|
||||
} catch (error) {
|
||||
// Dann gilt die ID nur für den aktuellen Seitenaufruf.
|
||||
}
|
||||
}
|
||||
|
||||
window.CMBNET_CLIENT_SESSION_ID = sessionId;
|
||||
window.CMBNET_CLIENT_ID = clientId;
|
||||
// Übergangsweise für noch gecachte ältere Skripte.
|
||||
window.CMBNET_CLIENT_SESSION_ID = clientId;
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/pico.min.css') }}">
|
||||
|
||||
Reference in new issue
Block a user