|
|
|
@ -0,0 +1,50 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Volo.Abp.Autofac;
|
|
|
|
|
using Volo.Abp.Http.Client.IdentityModel;
|
|
|
|
|
using Volo.Abp.Modularity;
|
|
|
|
|
|
|
|
|
|
namespace MyCompanyName.MyProjectName.Blazor
|
|
|
|
|
{
|
|
|
|
|
[DependsOn(
|
|
|
|
|
typeof(AbpAutofacModule),
|
|
|
|
|
typeof(MyProjectNameHttpApiClientModule),
|
|
|
|
|
typeof(AbpHttpClientIdentityModelModule)
|
|
|
|
|
)]
|
|
|
|
|
public class MyProjectNameBlazorModule : AbpModule
|
|
|
|
|
{
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
|
|
|
{
|
|
|
|
|
var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
|
|
|
|
|
var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();
|
|
|
|
|
|
|
|
|
|
ConfigureAuthentication(builder);
|
|
|
|
|
ConfigureHttpClient(context, environment);
|
|
|
|
|
ConfigureUI(builder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
builder.Services.AddOidcAuthentication(options =>
|
|
|
|
|
{
|
|
|
|
|
builder.Configuration.Bind("AuthServer", options.ProviderOptions);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConfigureUI(WebAssemblyHostBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
builder.RootComponents.Add<App>("app");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment)
|
|
|
|
|
{
|
|
|
|
|
context.Services.AddTransient(sp => new HttpClient
|
|
|
|
|
{
|
|
|
|
|
BaseAddress = new Uri(environment.BaseAddress)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|