mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.5 KiB
82 lines
2.5 KiB
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Volo.Abp;
|
|
using Volo.Abp.AspNetCore.Mvc;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
using Volo.Abp.EntityFrameworkCore.SqlServer;
|
|
using Volo.Abp.Identity.AspNetCore;
|
|
using Volo.Abp.Identity.EntityFrameworkCore;
|
|
using Volo.Abp.IdentityServer.EntityFrameworkCore;
|
|
using Volo.Abp.Modularity;
|
|
|
|
namespace IdentityServerHost
|
|
{
|
|
[DependsOn(
|
|
typeof(AbpAutofacModule),
|
|
typeof(AbpAspNetCoreMvcModule),
|
|
typeof(AbpIdentityAspNetCoreModule),
|
|
typeof(AbpIdentityServerEntityFrameworkCoreModule),
|
|
typeof(AbpIdentityEntityFrameworkCoreModule),
|
|
typeof(AbpEntityFrameworkCoreSqlServerModule)
|
|
)]
|
|
public class IdentityServerHostModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
var configuration = context.Services.BuildConfiguration();
|
|
|
|
Configure<DbConnectionOptions>(options =>
|
|
{
|
|
options.ConnectionStrings.Default = configuration.GetConnectionString("Default");
|
|
});
|
|
|
|
Configure<AbpDbContextOptions>(options =>
|
|
{
|
|
options.UseSqlServer();
|
|
});
|
|
|
|
Configure<IISOptions>(iis =>
|
|
{
|
|
iis.AuthenticationDisplayName = "Windows";
|
|
iis.AutomaticAuthentication = false;
|
|
});
|
|
|
|
context.Services.AddDistributedSqlServerCache(options =>
|
|
{
|
|
options.ConnectionString = configuration.GetConnectionString("SqlServerCache");
|
|
options.SchemaName = "dbo";
|
|
options.TableName = "TestCache";
|
|
});
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
|
|
app.UseVirtualFiles();
|
|
|
|
app.UseAuthentication();
|
|
|
|
app.UseIdentityServer();
|
|
|
|
app.UseMvcWithDefaultRoute();
|
|
|
|
SeedData(context);
|
|
}
|
|
|
|
private void SeedData(ApplicationInitializationContext context)
|
|
{
|
|
using (var scope = context.ServiceProvider.CreateScope())
|
|
{
|
|
scope.ServiceProvider
|
|
.GetRequiredService<IdentityServerDataSeeder>()
|
|
.Seed();
|
|
}
|
|
}
|
|
}
|
|
}
|