"Fix-security-and-config-from-TestAgent"
This commit is contained in:
parent
bbf5acbb6b
commit
1829e5c940
@ -289,7 +289,7 @@ public class BotsController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: Admin/Bots/RegenerateKey/5
|
// GET: Admin/Bots/RegenerateKey/5
|
||||||
public async Task<IActionResult> RegenerateKey(Guid id)
|
public IActionResult RegenerateKey(Guid id)
|
||||||
{
|
{
|
||||||
// This would require updating the bot model to support key regeneration
|
// This would require updating the bot model to support key regeneration
|
||||||
TempData["Error"] = "Key regeneration not yet implemented";
|
TempData["Error"] = "Key regeneration not yet implemented";
|
||||||
|
|||||||
@ -53,7 +53,9 @@ builder.Services.AddAuthentication("Cookies")
|
|||||||
|
|
||||||
builder.Services.AddAuthorization(options =>
|
builder.Services.AddAuthorization(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("AdminOnly", policy => policy.RequireAuthenticatedUser());
|
options.AddPolicy("AdminOnly", policy =>
|
||||||
|
policy.RequireAuthenticatedUser()
|
||||||
|
.RequireRole("Admin"));
|
||||||
options.AddPolicy("ApiAccess", policy => policy.RequireAuthenticatedUser());
|
options.AddPolicy("ApiAccess", policy => policy.RequireAuthenticatedUser());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -49,13 +49,13 @@ public class TelegramBotManagerService : BackgroundService, ITelegramBotManagerS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken)
|
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Telegram Bot Manager Service started");
|
_logger.LogInformation("Telegram Bot Manager Service started");
|
||||||
await base.StartAsync(cancellationToken);
|
await base.StartAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StopAsync(CancellationToken cancellationToken)
|
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Stopping all Telegram bots...");
|
_logger.LogInformation("Stopping all Telegram bots...");
|
||||||
|
|
||||||
@ -122,15 +122,15 @@ public class TelegramBotManagerService : BackgroundService, ITelegramBotManagerS
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> UpdateBotSettingsAsync(Guid botId)
|
public Task<bool> UpdateBotSettingsAsync(Guid botId)
|
||||||
{
|
{
|
||||||
if (_activeBots.TryGetValue(botId, out var botInstance))
|
if (_activeBots.TryGetValue(botId, out var botInstance))
|
||||||
{
|
{
|
||||||
// Reload settings from database
|
// Reload settings from database
|
||||||
_logger.LogInformation("Updating settings for bot {BotId}", botId);
|
_logger.LogInformation("Updating settings for bot {BotId}", botId);
|
||||||
return true;
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
return false;
|
return Task.FromResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> GetActiveBotCount()
|
public Task<int> GetActiveBotCount()
|
||||||
@ -174,7 +174,7 @@ public class TelegramBotManagerService : BackgroundService, ITelegramBotManagerS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PerformHealthChecksAsync()
|
private Task PerformHealthChecksAsync()
|
||||||
{
|
{
|
||||||
foreach (var kvp in _activeBots)
|
foreach (var kvp in _activeBots)
|
||||||
{
|
{
|
||||||
@ -189,6 +189,7 @@ public class TelegramBotManagerService : BackgroundService, ITelegramBotManagerS
|
|||||||
_logger.LogWarning(ex, "Health check failed for bot {BotId}", kvp.Key);
|
_logger.LogWarning(ex, "Health check failed for bot {BotId}", kvp.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user