mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2026-04-07 15:23:56 +00:00
Initial commit
This commit is contained in:
parent
2190113c56
commit
3088165398
1765 changed files with 192085 additions and 0 deletions
28
Chapter08/MyBlog/BlazorWebAssembly/Client/Program.cs
Normal file
28
Chapter08/MyBlog/BlazorWebAssembly/Client/Program.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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;
|
||||
|
||||
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.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();
|
||||
Loading…
Add table
Add a link
Reference in a new issue