diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Modularity/ApplicationInitializationContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs similarity index 95% rename from framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Modularity/ApplicationInitializationContextExtensions.cs rename to framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs index 2fe420a214..ed41314209 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Modularity/ApplicationInitializationContextExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Modularity +namespace Volo.Abp { public static class ApplicationInitializationContextExtensions { diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs index 1ef58ab901..d3e8055a22 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs @@ -10,7 +10,10 @@ namespace Volo.Abp.MongoDB { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.TryAddTransient(typeof(IMongoDbContextProvider<>), typeof(UnitOfWorkMongoDbContextProvider<>)); + context.Services.TryAddTransient( + typeof(IMongoDbContextProvider<>), + typeof(UnitOfWorkMongoDbContextProvider<>) + ); } } } diff --git a/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppModule.cs b/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppModule.cs index ffc03b5ff2..76556eda78 100644 --- a/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppModule.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.TestBase; using Volo.Abp.Json; diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs index 6ffd7ebf54..c1298d0e27 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs @@ -2,7 +2,6 @@ using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.Authorization; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.Localization.Resource; diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/AbpAspNetCoreMvcUiBootstrapDemoModule.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/AbpAspNetCoreMvcUiBootstrapDemoModule.cs index 2386ee6320..ce9734914d 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/AbpAspNetCoreMvcUiBootstrapDemoModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/AbpAspNetCoreMvcUiBootstrapDemoModule.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.Autofac; using Volo.Abp.Modularity; diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Versioning.Tests/Volo/Abp/AspNetCore/Mvc/Versioning/AbpAspNetCoreMvcVersioningTestModule.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Versioning.Tests/Volo/Abp/AspNetCore/Mvc/Versioning/AbpAspNetCoreMvcVersioningTestModule.cs index 2a4a399d28..728b119a19 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Versioning.Tests/Volo/Abp/AspNetCore/Mvc/Versioning/AbpAspNetCoreMvcVersioningTestModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Versioning.Tests/Volo/Abp/AspNetCore/Mvc/Versioning/AbpAspNetCoreMvcVersioningTestModule.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.TestBase; using Volo.Abp.Autofac; using Volo.Abp.Http.Client; diff --git a/samples/MicroserviceDemo/MicroserviceDemo.sln b/samples/MicroserviceDemo/MicroserviceDemo.sln index 45128e91d4..fb567f550b 100644 --- a/samples/MicroserviceDemo/MicroserviceDemo.sln +++ b/samples/MicroserviceDemo/MicroserviceDemo.sln @@ -61,7 +61,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BackendAdminApp.Host", "app EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "public", "public", "{76FA3B92-7837-4F04-B9E5-A13900F7DDA9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublicWebSite.Host", "applications\public\PublicWebSite.Host\PublicWebSite.Host.csproj", "{BBB502EC-0E3B-4C21-B8E6-59BFFBAC2055}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PublicWebSite.Host", "applications\public\PublicWebSite.Host\PublicWebSite.Host.csproj", "{BBB502EC-0E3B-4C21-B8E6-59BFFBAC2055}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "blogging", "blogging", "{203B8EC3-87FD-4F9A-8C56-294E5386F2B8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloggingService.Host", "microservices\blogging\BloggingService.Host\BloggingService.Host.csproj", "{61533609-BFF9-4B12-AB33-470FD65E326F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -141,6 +145,10 @@ Global {BBB502EC-0E3B-4C21-B8E6-59BFFBAC2055}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBB502EC-0E3B-4C21-B8E6-59BFFBAC2055}.Release|Any CPU.ActiveCfg = Release|Any CPU {BBB502EC-0E3B-4C21-B8E6-59BFFBAC2055}.Release|Any CPU.Build.0 = Release|Any CPU + {61533609-BFF9-4B12-AB33-470FD65E326F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61533609-BFF9-4B12-AB33-470FD65E326F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61533609-BFF9-4B12-AB33-470FD65E326F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61533609-BFF9-4B12-AB33-470FD65E326F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -173,6 +181,8 @@ Global {94D639F4-A6B5-4563-884F-5C58C7E8AF7E} = {F3F13E26-9121-4125-9417-851A54F84BDC} {76FA3B92-7837-4F04-B9E5-A13900F7DDA9} = {8F6834D7-E6FA-4A04-83BB-955F68EA0A0A} {BBB502EC-0E3B-4C21-B8E6-59BFFBAC2055} = {76FA3B92-7837-4F04-B9E5-A13900F7DDA9} + {203B8EC3-87FD-4F9A-8C56-294E5386F2B8} = {3B26D176-390B-4F51-BE52-E9B422C28A88} + {61533609-BFF9-4B12-AB33-470FD65E326F} = {203B8EC3-87FD-4F9A-8C56-294E5386F2B8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {37474F0D-2E52-4D2F-B39B-7FE3FF31B4EC} diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs index 62fa4b831d..db3c0d97ed 100644 --- a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs +++ b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; using Volo.Abp.Account.Web; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Autofac; diff --git a/samples/MicroserviceDemo/applications/backend/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/backend/BackendAdminApp.Host/BackendAdminAppHostModule.cs index bc550e26a0..c54eafc0dd 100644 --- a/samples/MicroserviceDemo/applications/backend/BackendAdminApp.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/backend/BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -5,7 +5,6 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.OAuth; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.Client; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.Autofac; diff --git a/samples/MicroserviceDemo/applications/public/PublicWebSite.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/public/PublicWebSite.Host/BackendAdminAppHostModule.cs index 0aa253b681..22b02348a2 100644 --- a/samples/MicroserviceDemo/applications/public/PublicWebSite.Host/BackendAdminAppHostModule.cs +++ b/samples/MicroserviceDemo/applications/public/PublicWebSite.Host/BackendAdminAppHostModule.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.OAuth; -using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.Client; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.Autofac; diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/BloggingService.Host.csproj b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/BloggingService.Host.csproj new file mode 100644 index 0000000000..7515abc246 --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/BloggingService.Host.csproj @@ -0,0 +1,41 @@ + + + + netcoreapp2.2 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + true + true + true + true + false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/BloggingServiceHostModule.cs new file mode 100644 index 0000000000..58261e80f4 --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/BloggingServiceHostModule.cs @@ -0,0 +1,84 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Swashbuckle.AspNetCore.Swagger; +using Volo.Abp; +using Volo.Abp.AuditLogging.EntityFrameworkCore; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.Security.Claims; +using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Blogging; +using Volo.Blogging.MongoDB; + +namespace BloggingService.Host +{ + [DependsOn( + typeof(AbpAutofacModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(BloggingHttpApiModule), + typeof(BloggingMongoDbModule), + typeof(BloggingApplicationModule) + )] + public class BloggingServiceHostModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAuthentication("Bearer") + .AddIdentityServerAuthentication(options => + { + options.Authority = "http://localhost:64999"; + options.RequireHttpsMetadata = false; + options.ApiName = "BloggingService"; + + //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) + options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; + options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; + options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email; + options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified; + options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber; + options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified; + options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName; + }); + + context.Services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new Info {Title = "Identity Service API", Version = "v1"}); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + }); + + Configure(options => + { + options.Languages.Add(new LanguageInfo("en", "en", "English")); + }); + + Configure(options => + { + options.UseSqlServer(); + }); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + + app.UseVirtualFiles(); + app.UseAuthentication(); + app.UseAbpRequestLocalization(); //TODO: localization? + app.UseSwagger(); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); + }); + app.UseAuditing(); + app.UseMvcWithDefaultRouteAndArea(); + } + } +} diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Program.cs b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Program.cs new file mode 100644 index 0000000000..00ace4e0c4 --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Program.cs @@ -0,0 +1,46 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Serilog; +using Serilog.Events; + +namespace BloggingService.Host +{ + public class Program + { + public static int Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .Enrich.FromLogContext() + .WriteTo.File("Logs/logs.txt") + .CreateLogger(); + + try + { + Log.Information("Starting IdentityService.Host."); + BuildWebHostInternal(args).Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "IdentityService.Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + } + + public static IWebHost BuildWebHostInternal(string[] args) => + new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .UseSerilog() + .Build(); + } +} diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Properties/launchSettings.json b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Properties/launchSettings.json new file mode 100644 index 0000000000..b8f8803266 --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:62157", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "BloggingService.Host": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Startup.cs b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Startup.cs new file mode 100644 index 0000000000..c0510c52de --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/Startup.cs @@ -0,0 +1,28 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Volo.Abp; + +namespace BloggingService.Host +{ + public class Startup + { + public IServiceProvider ConfigureServices(IServiceCollection services) + { + services.AddApplication(options => + { + options.UseAutofac(); + options.Configuration.UserSecretsAssembly = typeof(Startup).Assembly; + }); + + return services.BuildServiceProviderFromFactory(); + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); + } + } +} diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/appsettings.Development.json b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/appsettings.Development.json new file mode 100644 index 0000000000..e203e9407e --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/appsettings.json b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/appsettings.json new file mode 100644 index 0000000000..7653620db6 --- /dev/null +++ b/samples/MicroserviceDemo/microservices/blogging/BloggingService.Host/appsettings.json @@ -0,0 +1,12 @@ +{ + "ConnectionStrings": { + "Default": "Server=localhost;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", + "Blogging": "mongodb://localhost|MsDemo_Blogging" + }, + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs index 508ebd4557..9943328008 100644 --- a/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs +++ b/samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs @@ -2,7 +2,6 @@ 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;