Refactor: Server-Settings von appsettings.json in DB-Tabelle (server_settings)

- Neuer ServerSettingsService: zentrale Settings in SQLite mit In-Memory-Cache
- Auto-Migration: bestehende appsettings.Production.json wird einmalig in DB übernommen
- Alle Services umgestellt: IConfiguration → ServerSettingsService (dynamisch, kein Neustart)
- Port bleibt als einziges Setting in appsettings.Production.json (erfordert Neustart)
- ServerSettingsEndpoint: liest/schreibt DB statt JSON-Datei, Port als Sonder-Setting
- IConfiguration komplett entfernt aus allen Services (ChatService, ToolService, AnthropicService,
  OpenAiService, KreaService, TelegramService, KeyScannerService, GitHubEventScannerService)
- AuthMiddleware: KreaApiKey dynamisch aus DB
- appsettings.json bereinigt: nur noch Port und Logging
- Dokumentation aktualisiert (ARCHITECTURE.md, ARCHITECTURE_QUICK.md, README.md)
This commit is contained in:
Meleki committed 2026-03-14 13:06:44 +01:00
1 parent 542a031172
commit 122000487c
18 files changed
+389 -270

No files matched your search

+6 -6
View File
@@ -1,19 +1,18 @@
using System.Threading.Tasks;
using Gott.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
namespace Gott.Middleware;
public class AuthMiddleware
{
private readonly RequestDelegate _next;
private readonly string _kreaApiKey;
private readonly ServerSettingsService _settings;
public AuthMiddleware(RequestDelegate next, IConfiguration config)
public AuthMiddleware(RequestDelegate next, ServerSettingsService settings)
{
_next = next;
_kreaApiKey = config["KreaApiKey"] ?? "";
_settings = settings;
}
public async Task InvokeAsync(HttpContext ctx, AuthService auth, DatabaseService db)
@@ -34,10 +33,11 @@ public class AuthMiddleware
}
// Krea API-Key auth (for automation without user context)
if (path.StartsWith("/api/images/") && !string.IsNullOrEmpty(_kreaApiKey))
var kreaApiKey = _settings.Get("KreaApiKey");
if (path.StartsWith("/api/images/") && !string.IsNullOrEmpty(kreaApiKey))
{
var apiKey = ctx.Request.Headers["X-Api-Key"].ToString();
if (!string.IsNullOrEmpty(apiKey) && apiKey == _kreaApiKey)
if (!string.IsNullOrEmpty(apiKey) && apiKey == kreaApiKey)
{
await _next(ctx);
return;