Added authentication

This commit is contained in:
2026-06-21 20:10:02 +02:00
parent efe63211ed
commit a50be1ec0b
50 changed files with 2596 additions and 328 deletions
+10 -1
View File
@@ -3,6 +3,9 @@ using EonaCat.DoxaApi.Middleware;
var builder = WebApplication.CreateBuilder(args);
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
builder.Services.AddControllers();
builder.Services.AddDoxaApi(options =>
{
@@ -10,6 +13,12 @@ builder.Services.AddDoxaApi(options =>
options.Description = "A demo service showing off the DoxaApi UI - users and orders.";
options.Version = "v1";
options.AccentColor = "#6366f1";
// Declare how clients authenticate; DoxaApi auto-detects which endpoints
// require it via [Authorize] / [DoxaApiAuth] and renders an Authorize dialog.
options.AddBearerAuth(description: "Paste a JWT issued by /api/auth/login.");
options.AddApiKeyAuth("apiKey", "X-API-Key", description: "A static key for service-to-service calls.");
options.DefaultSecurityScheme = "bearer";
});
var app = builder.Build();
@@ -23,4 +32,4 @@ app.UseDoxaApi(options =>
app.MapControllers();
app.MapGet("/", () => Results.Redirect("/doxa"));
app.Run();
app.Run();