mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2025-12-06 05:32:03 +01:00
35 lines
1.7 KiB
C#
35 lines
1.7 KiB
C#
|
|
using BlazorWebAssembly.Client;
|
||
|
|
using Components.RazorComponents;
|
||
|
|
using Data;
|
||
|
|
using Data.Models.Interfaces;
|
||
|
|
using Microsoft.AspNetCore.Components.Web;
|
||
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
|
||
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||
|
|
using Blazored.SessionStorage;
|
||
|
|
using Components.Interfaces;
|
||
|
|
using BlazorWebAssembly.Client.Services;
|
||
|
|
|
||
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||
|
|
builder.RootComponents.Add<App>("#app");
|
||
|
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||
|
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
||
|
|
builder.Services.AddBlazoredSessionStorage();
|
||
|
|
builder.Services.AddScoped<IBrowserStorage, BlogBrowserStorage>();
|
||
|
|
builder.Services.AddSingleton<IBlogNotificationService, BlazorWebAssemblyBlogNotificationService>();
|
||
|
|
|
||
|
|
builder.Services.AddHttpClient("Public",
|
||
|
|
client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress));
|
||
|
|
builder.Services.AddHttpClient("Authenticated", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
|
||
|
|
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
|
||
|
|
builder.Services.AddTransient<IBlogApi, BlogApiWebClient>();
|
||
|
|
builder.Services.AddOidcAuthentication(options =>
|
||
|
|
{
|
||
|
|
builder.Configuration.Bind("Auth0", options.ProviderOptions);
|
||
|
|
options.ProviderOptions.ResponseType = "code";
|
||
|
|
options.ProviderOptions.AdditionalProviderParameters.Add("audience", builder.Configuration["Auth0:Audience"]);
|
||
|
|
}).AddAccountClaimsPrincipalFactory<ArrayClaimsPrincipalFactory<RemoteUserAccount>>();
|
||
|
|
|
||
|
|
builder.Services.AddTransient<ILoginStatus, LoginStatusWasm>();
|
||
|
|
|
||
|
|
await builder.Build().RunAsync();
|