mirror of
https://github.com/fiodarsazanavets/aspire-13-examples.git
synced 2026-06-20 12:23:14 +00:00
61 lines
1.3 KiB
C#
61 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
using OnlineShop.Web;
|
|
using OnlineShop.Web.Components;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.AddRedisOutputCache("cache");
|
|
|
|
builder.AddServiceDefaults();
|
|
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddOutputCache();
|
|
|
|
builder.Services.AddHttpClient(
|
|
"OidcBackchannel", o => o.BaseAddress = new("http://idp"));
|
|
|
|
builder.Services.AddHttpClient<ProductsApiClient>(client =>
|
|
{
|
|
client.BaseAddress = new("https+http://apiservice");
|
|
});
|
|
|
|
builder.Services.AddAuthentication(options =>
|
|
{
|
|
options.DefaultScheme =
|
|
CookieAuthenticationDefaults.AuthenticationScheme;
|
|
options.DefaultChallengeScheme =
|
|
OpenIdConnectDefaults.AuthenticationScheme;
|
|
})
|
|
.AddCookie(
|
|
CookieAuthenticationDefaults.AuthenticationScheme)
|
|
.AddOpenIdConnect()
|
|
.ConfigureWebAppOpenIdConnect();
|
|
|
|
builder.Services.AddHttpClient();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAntiforgery();
|
|
|
|
app.UseOutputCache();
|
|
|
|
app.MapStaticAssets();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.MapDefaultEndpoints();
|
|
|
|
app.Run();
|