WIP: Add Keycloak jwt bearer

This commit is contained in:
2025-08-03 12:19:29 +02:00
parent 164aa79dae
commit c981b24c60
8 changed files with 71 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
using PresentPortal.Shared;
var builder = WebApplication.CreateBuilder(args);
// Add service defaults & Aspire client integrations.
@@ -9,6 +11,14 @@ builder.Services.AddProblemDetails();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
builder.Services.AddAuthentication()
.AddKeycloakJwtBearer(ServiceNames.Keycloak, "TODO", options =>
{
options.Audience = "TODO";
options.Authority = "TODO";
// options.
});
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -19,6 +29,9 @@ if (app.Environment.IsDevelopment())
app.MapOpenApi();
}
app.UseAuthentication();
app.UseAuthorization();
string[] summaries =
["Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"];
@@ -34,7 +47,8 @@ app.MapGet("/weatherforecast", () =>
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast");
.WithName("GetWeatherForecast")
.RequireAuthorization();
app.MapDefaultEndpoints();