- Agent: Web-Suche als Dropdown (Deaktiviert / 2025 / 2026) statt bool - AnthropicService: web_search Tool dynamisch nach Version einfügen - Stream: server_tool_use + web_search_tool_result Events verarbeiten - Chat-Frontend: web_search_start/end Events mit Suchindikator - Dashboard: Badge zeigt Web-Suche mit Jahresversion - UserRecord: IsAdmin Feld, DB-Migration is_admin Spalte - AuthMiddleware: IsAdmin aus DB laden und in Context setzen - BackupEndpoint: Admin-Check (403 für Nicht-Admins) - AuthEndpoint: isAdmin in Login/Me Response - Frontend: Backup-Section nur für Admins sichtbar - Haiku 4.5 als Model-Option (Agent-Dropdown + ChatEndpoint) - TODO: Cronjobs, Haiku ergänzt
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Threading.Tasks;
|
|
using Gott.Services;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace Gott.Middleware;
|
|
|
|
public class AuthMiddleware
|
|
{
|
|
private readonly RequestDelegate _next;
|
|
|
|
public AuthMiddleware(RequestDelegate next)
|
|
{
|
|
_next = next;
|
|
}
|
|
|
|
public async Task InvokeAsync(HttpContext ctx, AuthService auth, DatabaseService db)
|
|
{
|
|
var path = ctx.Request.Path.Value ?? "";
|
|
|
|
// Static files and login endpoint don't require auth
|
|
if (!path.StartsWith("/api/") || path == "/api/auth/login")
|
|
{
|
|
await _next(ctx);
|
|
return;
|
|
}
|
|
|
|
var token = ctx.Request.Cookies["gott_token"];
|
|
var userId = auth.ValidateToken(token);
|
|
|
|
if (userId == null)
|
|
{
|
|
ctx.Response.StatusCode = 401;
|
|
await ctx.Response.WriteAsJsonAsync(new { error = "Not authenticated" });
|
|
return;
|
|
}
|
|
|
|
ctx.Items["UserId"] = userId;
|
|
|
|
var user = await db.GetUser(userId);
|
|
ctx.Items["IsAdmin"] = user?.IsAdmin ?? false;
|
|
|
|
await _next(ctx);
|
|
}
|
|
}
|