|
|
|
@ -1,17 +1,28 @@ |
|
|
|
using Microsoft.AspNetCore.Builder; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Swashbuckle.AspNetCore.Swagger; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.AspNetCore.Modularity; |
|
|
|
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
|
|
|
using Volo.Abp.Autofac; |
|
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
|
using Volo.Abp.EntityFrameworkCore.SqlServer; |
|
|
|
using Volo.Abp.Identity; |
|
|
|
using Volo.Abp.Identity.EntityFrameworkCore; |
|
|
|
using Volo.Abp.Localization; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|
|
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|
|
|
|
|
|
|
namespace IdentityService.Host |
|
|
|
{ |
|
|
|
[DependsOn( |
|
|
|
typeof(AbpAutofacModule), |
|
|
|
typeof(AbpEntityFrameworkCoreSqlServerModule), |
|
|
|
typeof(AbpAuditLoggingEntityFrameworkCoreModule), |
|
|
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
|
|
|
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
|
|
|
typeof(AbpIdentityHttpApiModule), |
|
|
|
typeof(AbpIdentityEntityFrameworkCoreModule), |
|
|
|
typeof(AbpIdentityApplicationModule) |
|
|
|
@ -20,9 +31,32 @@ namespace IdentityService.Host |
|
|
|
{ |
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
ConfigureAuthentication(context); |
|
|
|
ConfigureSwagger(context); |
|
|
|
//TODO: Configure localization?
|
|
|
|
var configuration = context.Services.GetConfiguration(); |
|
|
|
var x = configuration.GetConnectionString("Default"); |
|
|
|
|
|
|
|
context.Services.AddAuthentication("Bearer") |
|
|
|
.AddIdentityServerAuthentication(options => |
|
|
|
{ |
|
|
|
options.Authority = "http://localhost:64999"; //TODO: Update
|
|
|
|
options.RequireHttpsMetadata = false; |
|
|
|
options.ApiName = "IdentityService"; |
|
|
|
}); |
|
|
|
|
|
|
|
context.Services.AddSwaggerGen(options => |
|
|
|
{ |
|
|
|
options.SwaggerDoc("v1", new Info {Title = "Identity Service API", Version = "v1"}); |
|
|
|
options.DocInclusionPredicate((docName, description) => true); |
|
|
|
}); |
|
|
|
|
|
|
|
Configure<AbpLocalizationOptions>(options => |
|
|
|
{ |
|
|
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|
|
|
}); |
|
|
|
|
|
|
|
Configure<AbpDbContextOptions>(options => |
|
|
|
{ |
|
|
|
options.UseSqlServer(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|
|
|
@ -31,35 +65,14 @@ namespace IdentityService.Host |
|
|
|
|
|
|
|
app.UseVirtualFiles(); |
|
|
|
app.UseAuthentication(); |
|
|
|
//app.UseAbpRequestLocalization(); //TODO: localization?
|
|
|
|
app.UseAbpRequestLocalization(); //TODO: localization?
|
|
|
|
app.UseSwagger(); |
|
|
|
app.UseSwaggerUI(options => |
|
|
|
{ |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); |
|
|
|
}); |
|
|
|
app.UseAuditing(); |
|
|
|
app.UseMvcWithDefaultRoute(); |
|
|
|
} |
|
|
|
|
|
|
|
private void ConfigureAuthentication(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
context.Services.AddAuthentication("Bearer") |
|
|
|
.AddIdentityServerAuthentication(options => |
|
|
|
{ |
|
|
|
options.Authority = "http://localhost:9999"; //TODO: Update
|
|
|
|
options.RequireHttpsMetadata = false; |
|
|
|
options.ApiName = "IdentityService"; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private static void ConfigureSwagger(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
context.Services.AddSwaggerGen( |
|
|
|
options => |
|
|
|
{ |
|
|
|
options.SwaggerDoc("v1", new Info { Title = "Identity Service API", Version = "v1" }); |
|
|
|
options.DocInclusionPredicate((docName, description) => true); |
|
|
|
}); |
|
|
|
app.UseMvcWithDefaultRouteAndArea(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|