mirror of https://github.com/abpframework/abp.git
18 changed files with 263 additions and 11 deletions
@ -0,0 +1,41 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.2</TargetFramework> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
<PreserveCompilationContext>true</PreserveCompilationContext> |
|||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish> |
|||
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> |
|||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" /> |
|||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.MongoDB\Volo.Abp.MongoDB.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\blogging\src\Volo.Blogging.HttpApi\Volo.Blogging.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\blogging\src\Volo.Blogging.MongoDB\Volo.Blogging.MongoDB.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\blogging\src\Volo.Blogging.Application\Volo.Blogging.Application.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\audit-logging\src\Volo.Abp.AuditLogging.EntityFrameworkCore\Volo.Abp.AuditLogging.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.EntityFrameworkCore\Volo.Abp.PermissionManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore\Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -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<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
}); |
|||
|
|||
Configure<AbpDbContextOptions>(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(); |
|||
} |
|||
} |
|||
} |
|||
@ -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<Startup>() |
|||
.UseSerilog() |
|||
.Build(); |
|||
} |
|||
} |
|||
@ -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" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -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<BloggingServiceHostModule>(options => |
|||
{ |
|||
options.UseAutofac(); |
|||
options.Configuration.UserSecretsAssembly = typeof(Startup).Assembly; |
|||
}); |
|||
|
|||
return services.BuildServiceProviderFromFactory(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Debug", |
|||
"System": "Information", |
|||
"Microsoft": "Information" |
|||
} |
|||
} |
|||
} |
|||
@ -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": "*" |
|||
} |
|||
Loading…
Reference in new issue