Compare commits

...

2 Commits

Author SHA1 Message Date
c098e6430d Поменял папку с ключами
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 2m37s
2025-11-26 17:08:31 +03:00
3f30812d7a Небольшие фиксы
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 41s
2025-11-26 16:37:17 +03:00
3 changed files with 21 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ using System.Reflection;
using System.Threading.RateLimiting;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Identity.Web;
@@ -41,12 +42,19 @@ var timeLimit = int.TryParse(configuration["TIME_LIMIT"], out var parsedTimeLimi
#endregion
#region Работа с папкой данных
// создать папку data если не существует
// Создать папку data если не существует
var dataDirectory = Path.Combine(AppContext.BaseDirectory, "data");
if (!Directory.Exists(dataDirectory)) Directory.CreateDirectory(dataDirectory);
GlobalConsts.JwtFilePath = Path.Combine(dataDirectory, "jwt.txt");
// Создать подкаталог для плагинов
var pluginsPath = Path.Combine(dataDirectory, "Plugins");
if (!Directory.Exists(pluginsPath)) Directory.CreateDirectory(pluginsPath);
// Создать подкаталог для ключей Data Protection
var dataProtectionKeysDirectory = Path.Combine(dataDirectory, "keys");
if (!Directory.Exists(dataProtectionKeysDirectory)) Directory.CreateDirectory(dataProtectionKeysDirectory);
#endregion
#region Работа с логированием
@@ -79,7 +87,7 @@ builder.Services.AddHttpClient("modeus", client =>
client.BaseAddress = new Uri(configuration["MODEUS_URL"]!);
});
builder.Services.AddSingleton<ModeusHttpClient>();
builder.Services.AddScoped<ModeusService>();
builder.Services.AddSingleton<ModeusService>();
builder.Services.AddHttpClient("authClient");
builder.Services.AddAuthentication()
@@ -229,6 +237,10 @@ builder.Services.Configure<ForwardedHeadersOptions>(options =>
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("172.16.0.0"), 12)); // 172.16.x.x - 172.31.x.x
});
// Хранение ключей Data Protection в папке data
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(dataProtectionKeysDirectory));
var app = builder.Build();
var logger = app.Services.GetRequiredService<ILogger<Program>>();

View File

@@ -24,7 +24,7 @@ public class ModeusHttpClient
public void SetToken(string? token)
{
if (string.IsNullOrWhiteSpace(token)) {
_logger.LogErrorHere("Предоставленный токен пустой.");
_logger.LogInformationHere("Предоставленный токен пустой.");
return;
}

View File

@@ -32,7 +32,7 @@ public class ModeusService
if (schedule == null)
{
_logger.LogErrorHere($"schedule is null. {JsonSerializer.Serialize(msr, GlobalConsts.JsonSerializerOptions)}");
throw new Exception("Schedule is null");
return null;
}
Schedule? scheduleJson;
@@ -198,6 +198,11 @@ public class ModeusService
{
return await _modeusHttpClient.GetGuidAsync(fullname);
}
public async Task<List<Attendees>> GetAttendeesAsync(Guid eventId)
{
return await _modeusHttpClient.GetAttendeesAsync(eventId);
}
#endregion
}