Compare commits

..

1 Commits

Author SHA1 Message Date
ef827ba08b Upload code 2025-11-13 23:49:30 +03:00
2 changed files with 0 additions and 31 deletions

View File

@@ -14,27 +14,10 @@ if (string.IsNullOrWhiteSpace(builder.Configuration["MS_USERNAME"]) || string.Is
Environment.Exit(1);
}
var configuredApiKey = builder.Configuration["API_KEY"];
builder.Services.AddSingleton<MicrosoftAuthService>();
var app = builder.Build();
if (!string.IsNullOrWhiteSpace(configuredApiKey))
{
app.Use(async (context, next) =>
{
if (!context.Request.Headers.TryGetValue("X-API-Key", out var providedKey) || !string.Equals(providedKey, configuredApiKey, StringComparison.Ordinal))
{
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
await context.Response.WriteAsync("Unauthorized");
return;
}
await next();
});
}
app.MapGet("/auth/ms", async (MicrosoftAuthService mas, CancellationToken ct) =>
{
try

View File

@@ -1,14 +0,0 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5258",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}