mirror of https://github.com/abpframework/abp.git
7 changed files with 175 additions and 31 deletions
@ -1,13 +1,32 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>netcoreapp2.2</TargetFramework> |
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> |
<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> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="Microsoft.AspNetCore.App" /> |
<PackageReference Include="Microsoft.AspNetCore.App" /> |
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> |
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> |
||||
|
<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" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.Client\Volo.Abp.AspNetCore.Mvc.Client.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Authentication.OAuth\Volo.Abp.AspNetCore.Authentication.OAuth.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel\Volo.Abp.Http.Client.IdentityModel.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi.Client\Volo.Abp.Identity.HttpApi.Client.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.Web\Volo.Abp.Identity.Web.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,88 @@ |
|||||
|
using Microsoft.AspNetCore.Authentication.OAuth.Claims; |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
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; |
||||
|
using Volo.Abp.Http.Client.IdentityModel; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Identity.Web; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace BackendAdminApp.Host |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpAutofacModule), |
||||
|
typeof(AbpAspNetCoreMvcClientModule), |
||||
|
typeof(AbpAspNetCoreAuthenticationOAuthModule), |
||||
|
typeof(AbpHttpClientIdentityModelModule), |
||||
|
typeof(AbpIdentityHttpApiClientModule), |
||||
|
typeof(AbpIdentityWebModule), |
||||
|
typeof(AbpAspNetCoreMvcUiBasicThemeModule) |
||||
|
)] |
||||
|
public class BackendAdminAppHostModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
|
}); |
||||
|
|
||||
|
context.Services.AddAuthentication(options => |
||||
|
{ |
||||
|
options.DefaultScheme = "Cookies"; |
||||
|
options.DefaultChallengeScheme = "oidc"; |
||||
|
}) |
||||
|
.AddCookie("Cookies") |
||||
|
.AddOpenIdConnect("oidc", options => |
||||
|
{ |
||||
|
options.Authority = "http://localhost:64999"; |
||||
|
options.RequireHttpsMetadata = false; |
||||
|
options.ResponseType = OpenIdConnectResponseType.CodeIdToken; |
||||
|
|
||||
|
options.ClientId = "backend-admin-app-client"; |
||||
|
options.ClientSecret = "1q2w3e*"; |
||||
|
|
||||
|
options.SaveTokens = true; |
||||
|
options.GetClaimsFromUserInfoEndpoint = true; |
||||
|
|
||||
|
options.Scope.Add("role"); |
||||
|
options.Scope.Add("email"); |
||||
|
options.Scope.Add("phone"); |
||||
|
options.Scope.Add("IdentityService"); |
||||
|
//options.Scope.Add("ProductService"); //TODO: Enable once available
|
||||
|
|
||||
|
options.ClaimActions.MapAbpClaimTypes(); |
||||
|
}); |
||||
|
|
||||
|
context.Services.AddSwaggerGen( |
||||
|
options => |
||||
|
{ |
||||
|
options.SwaggerDoc("v1", new Info { Title = "Backend Admin Application API", Version = "v1" }); |
||||
|
options.DocInclusionPredicate((docName, description) => true); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
var app = context.GetApplicationBuilder(); |
||||
|
|
||||
|
app.UseVirtualFiles(); |
||||
|
app.UseAuthentication(); |
||||
|
app.UseAbpRequestLocalization(); |
||||
|
app.UseSwagger(); |
||||
|
app.UseSwaggerUI(options => |
||||
|
{ |
||||
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Backend Admin Application API"); |
||||
|
}); |
||||
|
app.UseMvcWithDefaultRouteAndArea(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace BackendAdminApp.Host.Controllers |
||||
|
{ |
||||
|
public class HomeController : AbpController |
||||
|
{ |
||||
|
public ActionResult Index() |
||||
|
{ |
||||
|
return Redirect("/Identity/Users"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,24 +1,46 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
|
||||
using System.IO; |
using System.IO; |
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore; |
|
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Hosting; |
||||
using Microsoft.Extensions.Configuration; |
using Serilog; |
||||
using Microsoft.Extensions.Logging; |
using Serilog.Events; |
||||
|
|
||||
namespace BackendAdminApp.Host |
namespace BackendAdminApp.Host |
||||
{ |
{ |
||||
public class Program |
public class Program |
||||
{ |
{ |
||||
public static void Main(string[] args) |
public static int Main(string[] args) |
||||
{ |
{ |
||||
CreateWebHostBuilder(args).Build().Run(); |
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Debug() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.File("Logs/logs.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Log.Information("Starting BackendAdminApp.Host."); |
||||
|
BuildWebHostInternal(args).Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "BackendAdminApp.Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => |
public static IWebHost BuildWebHostInternal(string[] args) => |
||||
WebHost.CreateDefaultBuilder(args) |
new WebHostBuilder() |
||||
.UseStartup<Startup>(); |
.UseKestrel() |
||||
|
.UseContentRoot(Directory.GetCurrentDirectory()) |
||||
|
.UseIISIntegration() |
||||
|
.UseStartup<Startup>() |
||||
|
.UseSerilog() |
||||
|
.Build(); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,34 +1,27 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Builder; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Hosting; |
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Volo.Abp; |
||||
|
|
||||
namespace BackendAdminApp.Host |
namespace BackendAdminApp.Host |
||||
{ |
{ |
||||
public class Startup |
public class Startup |
||||
{ |
{ |
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
public IServiceProvider ConfigureServices(IServiceCollection services) |
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
{ |
||||
|
services.AddApplication<BackendAdminAppHostModule>(options => |
||||
|
{ |
||||
|
options.UseAutofac(); |
||||
|
}); |
||||
|
|
||||
|
return services.BuildServiceProviderFromFactory(); |
||||
} |
} |
||||
|
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) |
|
||||
{ |
{ |
||||
if (env.IsDevelopment()) |
app.InitializeApplication(); |
||||
{ |
|
||||
app.UseDeveloperExceptionPage(); |
|
||||
} |
|
||||
|
|
||||
app.Run(async (context) => |
|
||||
{ |
|
||||
await context.Response.WriteAsync("Hello World!"); |
|
||||
}); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue