feat(telegram): Zugriffskontrolle mit Chat-ID-Whitelist
- TelegramService: IsChatIdAllowed() prüft Owner + Whitelist - /start von unbekannter ChatId: Zugriff verweigert + ChatId angezeigt - Owner wird bei Zugriffsanfrage benachrichtigt (Username + ChatId) - Alle Commands/Messages prüfen Whitelist vor Verarbeitung - Neues Feld telegram_allowed_chat_ids in sessions-Tabelle - Frontend: Input für erlaubte Chat-IDs in Session-Telegram-Settings - API: allowedChatIds in Save/Get durchgereicht
This commit is contained in:
1 parent
5661e55898
commit
011b26c37f
7 files changed
+91
-10
No files matched your search
@@ -81,8 +81,9 @@ public static class TelegramEndpoint
|
||||
var body = await JsonSerializer.DeserializeAsync<JsonElement>(req.Body);
|
||||
var botToken = body.TryGetProperty("botToken", out var t) ? t.GetString() : null;
|
||||
var webhookSecret = body.TryGetProperty("webhookSecret", out var s) ? s.GetString() : null;
|
||||
var allowedChatIds = body.TryGetProperty("allowedChatIds", out var a) ? a.GetString() : session.TelegramAllowedChatIds;
|
||||
|
||||
await db.UpdateSessionTelegram(sessionId, botToken, webhookSecret, session.TelegramChatId);
|
||||
await db.UpdateSessionTelegram(sessionId, botToken, webhookSecret, session.TelegramChatId, allowedChatIds);
|
||||
await res.WriteAsJsonAsync(new { ok = true });
|
||||
}
|
||||
|
||||
@@ -102,6 +103,7 @@ public static class TelegramEndpoint
|
||||
botToken = session.TelegramBotToken ?? "",
|
||||
webhookSecret = session.TelegramWebhookSecret ?? "",
|
||||
chatId = session.TelegramChatId ?? "",
|
||||
allowedChatIds = session.TelegramAllowedChatIds ?? "",
|
||||
configured = !string.IsNullOrEmpty(session.TelegramBotToken)
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user