Compare commits
2 Commits
bed42a83bf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c098e6430d | |||
| 3f30812d7a |
@@ -3,6 +3,7 @@ using System.Reflection;
|
|||||||
using System.Threading.RateLimiting;
|
using System.Threading.RateLimiting;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||||
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||||
using Microsoft.Identity.Web;
|
using Microsoft.Identity.Web;
|
||||||
@@ -41,12 +42,19 @@ var timeLimit = int.TryParse(configuration["TIME_LIMIT"], out var parsedTimeLimi
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Работа с папкой данных
|
#region Работа с папкой данных
|
||||||
// создать папку data если не существует
|
// Создать папку data если не существует
|
||||||
var dataDirectory = Path.Combine(AppContext.BaseDirectory, "data");
|
var dataDirectory = Path.Combine(AppContext.BaseDirectory, "data");
|
||||||
if (!Directory.Exists(dataDirectory)) Directory.CreateDirectory(dataDirectory);
|
if (!Directory.Exists(dataDirectory)) Directory.CreateDirectory(dataDirectory);
|
||||||
|
|
||||||
GlobalConsts.JwtFilePath = Path.Combine(dataDirectory, "jwt.txt");
|
GlobalConsts.JwtFilePath = Path.Combine(dataDirectory, "jwt.txt");
|
||||||
|
|
||||||
|
// Создать подкаталог для плагинов
|
||||||
var pluginsPath = Path.Combine(dataDirectory, "Plugins");
|
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
|
#endregion
|
||||||
|
|
||||||
#region Работа с логированием
|
#region Работа с логированием
|
||||||
@@ -79,7 +87,7 @@ builder.Services.AddHttpClient("modeus", client =>
|
|||||||
client.BaseAddress = new Uri(configuration["MODEUS_URL"]!);
|
client.BaseAddress = new Uri(configuration["MODEUS_URL"]!);
|
||||||
});
|
});
|
||||||
builder.Services.AddSingleton<ModeusHttpClient>();
|
builder.Services.AddSingleton<ModeusHttpClient>();
|
||||||
builder.Services.AddScoped<ModeusService>();
|
builder.Services.AddSingleton<ModeusService>();
|
||||||
builder.Services.AddHttpClient("authClient");
|
builder.Services.AddHttpClient("authClient");
|
||||||
|
|
||||||
builder.Services.AddAuthentication()
|
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
|
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 app = builder.Build();
|
||||||
|
|
||||||
var logger = app.Services.GetRequiredService<ILogger<Program>>();
|
var logger = app.Services.GetRequiredService<ILogger<Program>>();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class ModeusHttpClient
|
|||||||
public void SetToken(string? token)
|
public void SetToken(string? token)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(token)) {
|
if (string.IsNullOrWhiteSpace(token)) {
|
||||||
_logger.LogErrorHere("Предоставленный токен пустой.");
|
_logger.LogInformationHere("Предоставленный токен пустой.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class ModeusService
|
|||||||
if (schedule == null)
|
if (schedule == null)
|
||||||
{
|
{
|
||||||
_logger.LogErrorHere($"schedule is null. {JsonSerializer.Serialize(msr, GlobalConsts.JsonSerializerOptions)}");
|
_logger.LogErrorHere($"schedule is null. {JsonSerializer.Serialize(msr, GlobalConsts.JsonSerializerOptions)}");
|
||||||
throw new Exception("Schedule is null");
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schedule? scheduleJson;
|
Schedule? scheduleJson;
|
||||||
@@ -198,6 +198,11 @@ public class ModeusService
|
|||||||
{
|
{
|
||||||
return await _modeusHttpClient.GetGuidAsync(fullname);
|
return await _modeusHttpClient.GetGuidAsync(fullname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<Attendees>> GetAttendeesAsync(Guid eventId)
|
||||||
|
{
|
||||||
|
return await _modeusHttpClient.GetAttendeesAsync(eventId);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user