deploy: fix TemplateResponse signature

This commit is contained in:
Antigravity
2026-06-24 22:10:04 +00:00
commit 458cdaa3c2
78 changed files with 2085 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+49
View File
@@ -0,0 +1,49 @@
{% extends "base.html" %}
{% block content %}
<div class="mb-6 flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-white">Audit Logs</h1>
<p class="text-gray-400 mt-2">History of API and MCP accesses by agents.</p>
</div>
<a href="/dashboard" class="text-gray-400 hover:text-white">&larr; Back to Dashboard</a>
</div>
<div class="bg-gray-800 rounded-lg shadow border border-gray-700 p-6">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead>
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Time</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Agent</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Scope / Action</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">IP Address</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
{% for log in logs %}
<tr class="hover:bg-gray-750 transition">
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-400">{{ log.timestamp }}</td>
<td class="px-4 py-4 whitespace-nowrap text-sm font-medium text-gray-200">{{ log.agent_name }}</td>
<td class="px-4 py-4 whitespace-nowrap text-sm">
{% if 'FORBIDDEN' in log.scope %}
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-900 text-red-200 border border-red-700">
{{ log.scope }}
</span>
{% else %}
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-700 text-gray-300">
{{ log.scope }}
</span>
{% endif %}
</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500 font-mono">{{ log.ip_address }}</td>
</tr>
{% endfor %}
{% if not logs %}
<tr><td colspan="4" class="px-4 py-6 text-gray-500 text-center text-sm italic">No logs available</td></tr>
{% endif %}
</tbody>
</table>
</div>
</div>
{% endblock %}
+58
View File
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}context-hub | Nyora Infrastructure{% endblock %}</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
nyora: '#d4a01a'
}
}
}
}
</script>
<link rel="stylesheet" href="/static/style.css">
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen flex flex-col font-sans">
{% if request.url.path != "/login" %}
<nav class="bg-gray-800 border-b border-gray-700">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0 text-nyora font-bold text-xl tracking-wider">
CONTEXT-HUB
</div>
<div class="hidden md:block">
<div class="ml-10 flex items-baseline space-x-4">
<a href="/dashboard" class="text-gray-300 hover:text-white hover:bg-gray-700 px-3 py-2 rounded-md text-sm font-medium">Dashboard</a>
<a href="/audit" class="text-gray-300 hover:text-white hover:bg-gray-700 px-3 py-2 rounded-md text-sm font-medium">Audit Logs</a>
<a href="/keys" class="text-gray-300 hover:text-white hover:bg-gray-700 px-3 py-2 rounded-md text-sm font-medium">API Keys</a>
</div>
</div>
</div>
<div>
<a href="/auth/logout" class="text-gray-400 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Logout</a>
</div>
</div>
</div>
</nav>
{% endif %}
<main class="flex-grow w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{% block content %}{% endblock %}
</main>
<footer class="bg-gray-900 py-6 border-t border-gray-800 text-center">
<p class="text-nyora font-medium uppercase tracking-widest text-sm">Nyora</p>
<p class="text-gray-500 text-xs mt-1">Crafted with precision | 2026</p>
</footer>
</body>
</html>
+63
View File
@@ -0,0 +1,63 @@
{% extends "base.html" %}
{% block content %}
<div class="mb-8">
<h1 class="text-3xl font-bold text-white">Dashboard</h1>
<p class="text-gray-400 mt-2">Manage scopes, rules and monitor agent activity.</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<!-- Scopes section -->
<div class="bg-gray-800 rounded-lg shadow border border-gray-700 p-6">
<h2 class="text-xl font-semibold text-nyora mb-4">Rule Scopes</h2>
<ul class="divide-y divide-gray-700">
{% for scope in rules.keys() %}
<li class="py-4 flex items-center justify-between">
<div class="flex items-center">
<span class="text-white font-medium text-lg uppercase">{{ scope }}</span>
</div>
<a href="/editor/{{ scope }}" class="px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white text-sm font-medium rounded-md transition">Edit Rules</a>
</li>
{% endfor %}
{% if not rules %}
<li class="py-4 text-gray-500 italic">No scopes available.</li>
{% endif %}
</ul>
</div>
<!-- Quick Stats or Audit snippet -->
<div class="bg-gray-800 rounded-lg shadow border border-gray-700 p-6">
<h2 class="text-xl font-semibold text-nyora mb-4">Recent Activity</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead>
<tr>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Agent</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Scope</th>
<th class="px-3 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Time</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
{% for log in logs[:10] %}
<tr>
<td class="px-3 py-3 whitespace-nowrap text-sm text-gray-300">{{ log.agent_name }}</td>
<td class="px-3 py-3 whitespace-nowrap text-sm">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-700 text-gray-300">
{{ log.scope }}
</span>
</td>
<td class="px-3 py-3 whitespace-nowrap text-sm text-gray-500">{{ log.timestamp }}</td>
</tr>
{% endfor %}
{% if not logs %}
<tr><td colspan="3" class="px-3 py-4 text-gray-500 text-center text-sm italic">No recent activity</td></tr>
{% endif %}
</tbody>
</table>
</div>
<div class="mt-4 text-right">
<a href="/audit" class="text-nyora hover:text-yellow-400 text-sm font-medium">View all logs &rarr;</a>
</div>
</div>
</div>
{% endblock %}
+64
View File
@@ -0,0 +1,64 @@
{% extends "base.html" %}
{% block content %}
<div class="mb-6 flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-white uppercase">{{ scope }} Scope Editor</h1>
<p class="text-gray-400 mt-2">Edit rules for the <span class="font-bold text-gray-200">{{ scope }}</span> scope (JSON format).</p>
</div>
<a href="/dashboard" class="text-gray-400 hover:text-white">&larr; Back to Dashboard</a>
</div>
<div class="bg-gray-800 rounded-lg shadow border border-gray-700 p-6">
<div id="alert-box" class="hidden mb-4 p-4 rounded-md text-sm"></div>
<form id="editor-form" class="space-y-4">
<div>
<textarea id="json-editor" rows="20" class="w-full bg-gray-900 text-gray-100 font-mono text-sm p-4 rounded-md border border-gray-600 focus:border-nyora focus:ring-1 focus:ring-nyora transition"></textarea>
</div>
<div class="flex justify-end">
<button type="button" onclick="saveRules()" class="px-6 py-2 bg-nyora text-gray-900 font-medium rounded-md hover:bg-yellow-500 transition shadow-sm">Save Changes</button>
</div>
</form>
</div>
<script>
const initialContent = {{ content | tojson | safe }};
const textarea = document.getElementById('json-editor');
const alertBox = document.getElementById('alert-box');
const scope = "{{ scope }}";
textarea.value = JSON.stringify(initialContent, null, 2);
function showAlert(message, isError=false) {
alertBox.textContent = message;
alertBox.className = `mb-4 p-4 rounded-md text-sm font-medium ${isError ? 'bg-red-900 text-red-200 border border-red-700' : 'bg-green-900 text-green-200 border border-green-700'}`;
alertBox.classList.remove('hidden');
setTimeout(() => { alertBox.classList.add('hidden'); }, 4000);
}
async function saveRules() {
let data;
try {
data = JSON.parse(textarea.value);
} catch (e) {
showAlert("Invalid JSON format. Please check syntax.", true);
return;
}
try {
const response = await fetch(`/api/admin/rules/${scope}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
if (response.ok) {
showAlert("Rules successfully saved!");
} else {
showAlert("Error saving rules: " + response.statusText, true);
}
} catch(e) {
showAlert("Network error.", true);
}
}
</script>
{% endblock %}
+71
View File
@@ -0,0 +1,71 @@
{% extends "base.html" %}
{% block content %}
<div class="mb-6 flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-white">API Keys</h1>
<p class="text-gray-400 mt-2">Manage access keys for all agents.</p>
</div>
<a href="/dashboard" class="text-gray-400 hover:text-white">&larr; Back to Dashboard</a>
</div>
<div class="bg-gray-800 rounded-lg shadow border border-gray-700 p-6">
<div id="alert-box" class="hidden mb-4 p-4 rounded-md text-sm"></div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead>
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Agent</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">API Key</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Last Used</th>
<th class="px-4 py-3 text-right text-xs font-medium text-gray-400 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
{% for key in keys %}
<tr class="hover:bg-gray-750 transition" id="row-{{ key.agent_name }}">
<td class="px-4 py-4 whitespace-nowrap text-sm font-bold text-nyora">{{ key.agent_name }}</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-300 font-mono" id="key-{{ key.agent_name }}">{{ key.api_key }}</td>
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">{{ key.last_used or 'Never' }}</td>
<td class="px-4 py-4 whitespace-nowrap text-right text-sm font-medium">
<button onclick="rotateKey('{{ key.agent_name }}')" class="text-yellow-500 hover:text-yellow-400">Rotate</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<script>
const alertBox = document.getElementById('alert-box');
function showAlert(message, isError=false) {
alertBox.textContent = message;
alertBox.className = `mb-4 p-4 rounded-md text-sm font-medium ${isError ? 'bg-red-900 text-red-200 border border-red-700' : 'bg-green-900 text-green-200 border border-green-700'}`;
alertBox.classList.remove('hidden');
setTimeout(() => { alertBox.classList.add('hidden'); }, 4000);
}
async function rotateKey(agent) {
if (!confirm(`Are you sure you want to rotate the key for ${agent}? This will immediately revoke the old key.`)) {
return;
}
try {
const response = await fetch(`/api/keys/rotate/${agent}`, {
method: 'POST'
});
const data = await response.json();
if (response.ok) {
document.getElementById(`key-${agent}`).textContent = data.new_key;
showAlert(`Key for ${agent} rotated successfully.`);
} else {
showAlert(`Error rotating key: ${data.detail}`, true);
}
} catch(e) {
showAlert("Network error.", true);
}
}
</script>
{% endblock %}
+25
View File
@@ -0,0 +1,25 @@
{% extends "base.html" %}
{% block content %}
<div class="flex items-center justify-center h-[70vh]">
<div class="bg-gray-800 p-8 rounded-lg shadow-xl w-full max-w-md border border-gray-700">
<h2 class="text-2xl font-bold text-nyora mb-6 text-center">Nyora Infrastructure</h2>
<form action="/auth/login" method="POST" class="space-y-6">
<div>
<label for="username" class="block text-sm font-medium text-gray-400">Username</label>
<input type="text" id="username" name="username" placeholder="Identifiant" required
class="mt-1 block w-full px-4 py-3 bg-gray-900 border border-gray-600 rounded-md text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-nyora focus:border-transparent transition">
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-400">Password</label>
<input type="password" id="password" name="password" placeholder="Mot de passe" required
class="mt-1 block w-full px-4 py-3 bg-gray-900 border border-gray-600 rounded-md text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-nyora focus:border-transparent transition">
</div>
<button type="submit"
class="w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-gray-900 bg-nyora hover:bg-yellow-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-nyora focus:ring-offset-gray-900 transition">
Sign In
</button>
</form>
</div>
</div>
{% endblock %}