diff --git a/.gitignore b/.gitignore index b6366f8011..7c1b4951fa 100644 --- a/.gitignore +++ b/.gitignore @@ -286,3 +286,4 @@ modules/blogging/app/Volo\.BloggingTestApp/package-lock\.json templates/mvc/src/MyCompanyName\.MyProjectName\.Web/package-lock\.json samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Logs/logs.txt +samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Logs/logs.txt diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs index 369c8017e8..62fa4b831d 100644 --- a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs +++ b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs @@ -10,7 +10,6 @@ using Volo.Abp.Autofac; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.SqlServer; using Volo.Abp.Identity; -using Volo.Abp.Identity.AspNetCore; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.Localization; diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Program.cs b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Program.cs index 0c007999da..84f71ab802 100644 --- a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Program.cs +++ b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Program.cs @@ -19,13 +19,13 @@ namespace AuthServer.Host try { - Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); + Log.Information("Starting AuthServer.Host."); BuildWebHostInternal(args).Run(); return 0; } catch (Exception ex) { - Log.Fatal(ex, "Host terminated unexpectedly!"); + Log.Fatal(ex, "AuthServer.Host terminated unexpectedly!"); return 1; } finally diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs index 594ec2f488..a80027ad0d 100644 --- a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs +++ b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs @@ -22,6 +22,7 @@ namespace AuthServer.Host public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { + //TODO: Need to this? loggerFactory .AddConsole() .AddDebug() diff --git a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityService.Host.csproj b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityService.Host.csproj index 3dd131c70b..52dd6cf099 100644 --- a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityService.Host.csproj +++ b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityService.Host.csproj @@ -2,12 +2,13 @@ netcoreapp2.2 - InProcess $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; true true true true + false + true @@ -20,9 +21,13 @@ + + + + diff --git a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs index f96087c9d2..b721b51449 100644 --- a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs @@ -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(options => + { + options.Languages.Add(new LanguageInfo("en", "en", "English")); + }); + + Configure(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(); } } } diff --git a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs index 5c2025efbf..679d812bd7 100644 --- a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs +++ b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs @@ -15,6 +15,7 @@ namespace IdentityService.Host services.AddApplication(options => { options.UseAutofac(); + options.Configuration.UserSecretsAssembly = typeof(Startup).Assembly; }); return services.BuildServiceProviderFromFactory();