API Key Config ist fertig

Dieser Commit ist enthalten in:
2025-06-22 12:03:49 +02:00
Ursprung b420452551
Commit 1b5b7d0381
7 geänderte Dateien mit 398 neuen und 40 gelöschten Zeilen

Datei anzeigen

@@ -98,6 +98,112 @@
</div>
</div>
<!-- System API Key Section -->
<div class="row mb-4">
<div class="col-12">
<div class="card">
<div class="card-header bg-warning text-dark">
<h5 class="mb-0"><i class="bi bi-key"></i> System API Key</h5>
</div>
<div class="card-body">
{% if system_api_key %}
<div class="row mb-3">
<div class="col-md-12">
<label class="form-label fw-bold">Aktueller API Key:</label>
<div class="input-group">
<input type="text" class="form-control font-monospace" id="systemApiKey"
value="{{ system_api_key.api_key }}" readonly>
<button class="btn btn-outline-secondary" type="button" onclick="copySystemApiKey()">
<i class="bi bi-clipboard"></i> Kopieren
</button>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h6>Key Informationen:</h6>
<ul class="list-unstyled small">
<li><strong>Erstellt:</strong>
{% if system_api_key.created_at %}
{{ system_api_key.created_at.strftime('%d.%m.%Y %H:%M') }}
{% else %}
N/A
{% endif %}
</li>
<li><strong>Erstellt von:</strong> {{ system_api_key.created_by or 'System' }}</li>
{% if system_api_key.regenerated_at %}
<li><strong>Zuletzt regeneriert:</strong>
{{ system_api_key.regenerated_at.strftime('%d.%m.%Y %H:%M') }}
</li>
<li><strong>Regeneriert von:</strong> {{ system_api_key.regenerated_by }}</li>
{% else %}
<li><strong>Zuletzt regeneriert:</strong> Nie</li>
{% endif %}
</ul>
</div>
<div class="col-md-6">
<h6>Nutzungsstatistiken:</h6>
<ul class="list-unstyled small">
<li><strong>Letzte Nutzung:</strong>
{% if system_api_key.last_used_at %}
{{ system_api_key.last_used_at.strftime('%d.%m.%Y %H:%M') }}
{% else %}
Noch nie genutzt
{% endif %}
</li>
<li><strong>Gesamte Anfragen:</strong> {{ system_api_key.usage_count or 0 }}</li>
</ul>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<form action="{{ url_for('admin.regenerate_api_key') }}" method="POST"
onsubmit="return confirmRegenerate()">
<button type="submit" class="btn btn-warning">
<i class="bi bi-arrow-clockwise"></i> API Key regenerieren
</button>
<span class="text-muted ms-2">
<i class="bi bi-exclamation-triangle"></i>
Dies wird den aktuellen Key ungültig machen!
</span>
</form>
</div>
</div>
<div class="mt-3">
<details>
<summary class="text-primary" style="cursor: pointer;">Verwendungsbeispiel anzeigen</summary>
<div class="mt-2">
<pre class="bg-light p-3"><code>import requests
headers = {
"X-API-Key": "{{ system_api_key.api_key }}",
"Content-Type": "application/json"
}
response = requests.post(
"{{ request.url_root }}api/license/verify",
headers=headers,
json={"license_key": "YOUR_LICENSE_KEY"}
)</code></pre>
</div>
</details>
</div>
{% else %}
<div class="alert alert-danger">
<i class="bi bi-exclamation-triangle"></i> Kein System API Key gefunden!
Bitte kontaktieren Sie den Administrator.
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Technical Settings (collapsible) -->
<div class="accordion mb-4" id="technicalSettings">
<!-- Feature Flags -->
@@ -213,6 +319,32 @@ function copyToClipboard(text) {
});
}
function copySystemApiKey() {
const apiKeyInput = document.getElementById('systemApiKey');
apiKeyInput.select();
apiKeyInput.setSelectionRange(0, 99999);
navigator.clipboard.writeText(apiKeyInput.value).then(function() {
const button = event.currentTarget;
const originalHTML = button.innerHTML;
button.innerHTML = '<i class="bi bi-check"></i> Kopiert!';
button.classList.remove('btn-outline-secondary');
button.classList.add('btn-success');
setTimeout(() => {
button.innerHTML = originalHTML;
button.classList.remove('btn-success');
button.classList.add('btn-outline-secondary');
}, 2000);
});
}
function confirmRegenerate() {
return confirm('Sind Sie sicher, dass Sie den API Key regenerieren möchten?\n\n' +
'Dies wird den aktuellen Key ungültig machen und alle bestehenden ' +
'Integrationen müssen mit dem neuen Key aktualisiert werden.');
}
// Auto-refresh sessions every 30 seconds
function refreshSessions() {
fetch('{{ url_for("admin.license_live_stats") }}')