build: 版本升级到netcore3.0
This commit is contained in:
parent
74c5f7e2f5
commit
4986c14ded
|
@ -84,6 +84,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{85574E
|
||||||
src\admin\Bootstrap.Admin\Linux.Dockerfile = src\admin\Bootstrap.Admin\Linux.Dockerfile
|
src\admin\Bootstrap.Admin\Linux.Dockerfile = src\admin\Bootstrap.Admin\Linux.Dockerfile
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap.Security.Mvc", "..\Utility\Bootstrap.Security.Mvc\src\Bootstrap.Security.Mvc\Bootstrap.Security.Mvc.csproj", "{A44BB5C0-BB27-482B-B1F1-DF79AC070C4E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -118,6 +120,10 @@ Global
|
||||||
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A44BB5C0-BB27-482B-B1F1-DF79AC070C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A44BB5C0-BB27-482B-B1F1-DF79AC070C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A44BB5C0-BB27-482B-B1F1-DF79AC070C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A44BB5C0-BB27-482B-B1F1-DF79AC070C4E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -137,6 +143,7 @@ Global
|
||||||
{843811A2-FE49-410F-BF9F-9F1FB14A1DEE} = {C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0}
|
{843811A2-FE49-410F-BF9F-9F1FB14A1DEE} = {C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0}
|
||||||
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5} = {C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0}
|
{BC1C6D63-ADA9-4C3B-89F0-CEB191A86BF5} = {C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0}
|
||||||
{E03B7391-B52F-4449-B400-5CD9DE01F085} = {41B6D37A-5E5E-42B3-85E4-D81A81E3D757}
|
{E03B7391-B52F-4449-B400-5CD9DE01F085} = {41B6D37A-5E5E-42B3-85E4-D81A81E3D757}
|
||||||
|
{A44BB5C0-BB27-482B-B1F1-DF79AC070C4E} = {E03B7391-B52F-4449-B400-5CD9DE01F085}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {221EAE38-5F75-4391-9A48-E462A9F3B8FC}
|
SolutionGuid = {221EAE38-5F75-4391-9A48-E462A9F3B8FC}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
|
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Target Condition=" '$(TargetFramework)' == 'netcoreapp2.2' " Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Condition=" '$(TargetFramework)' == 'netcoreapp2.2' or '$(TargetFramework)' == 'netcoreapp3.0' " Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
<Message Text="Copy file -> $(TargetDir)" Importance="high" />
|
<Message Text="Copy file -> $(TargetDir)" Importance="high" />
|
||||||
<Copy Condition="'$(OS)' == 'Windows_NT'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)src\admin\keys\Longbow.lic" SkipUnchangedFiles="true" />
|
<Copy Condition="'$(OS)' == 'Windows_NT'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)src\admin\keys\Longbow.lic" SkipUnchangedFiles="true" />
|
||||||
<Copy Condition="'$(OS)' == 'UNIX'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)src/admin/keys/Longbow.lic" SkipUnchangedFiles="true" />
|
<Copy Condition="'$(OS)' == 'UNIX'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)src/admin/keys/Longbow.lic" SkipUnchangedFiles="true" />
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
|
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DocumentationFile>$(MSBuildProjectName).xml</DocumentationFile>
|
<DocumentationFile>$(MSBuildProjectName).xml</DocumentationFile>
|
||||||
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
|
||||||
|
@ -11,18 +12,14 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.21" />
|
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.21" />
|
||||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.17" />
|
|
||||||
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
||||||
<PackageReference Include="Longbow.Tasks" Version="2.2.23" />
|
<PackageReference Include="Longbow.Tasks" Version="2.2.23" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.6" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
<PackageReference Include="Sentry.AspNetCore" Version="1.2.0" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\Utility\Bootstrap.Security.Mvc\src\Bootstrap.Security.Mvc\Bootstrap.Security.Mvc.csproj" />
|
||||||
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
|
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace Bootstrap.Admin.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="host"></param>
|
/// <param name="host"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ActionResult Profiles([FromServices]IHostingEnvironment host) => View(new ProfilesModel(this, host));
|
public ActionResult Profiles([FromServices]IWebHostEnvironment host) => View(new ProfilesModel(this, host));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Bootstrap.DataAccess;
|
using Bootstrap.DataAccess;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
@ -24,7 +24,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
[ButtonAuthorize(Url = "~/Admin/Profiles", Auth = "saveIcon")]
|
[ButtonAuthorize(Url = "~/Admin/Profiles", Auth = "saveIcon")]
|
||||||
public JsonResult Post(string id, [FromServices]IHostingEnvironment env, [FromForm]DeleteFileCollection files)
|
public JsonResult Post(string id, [FromServices]IWebHostEnvironment env, [FromForm]DeleteFileCollection files)
|
||||||
{
|
{
|
||||||
if (!id.Equals("Delete", StringComparison.OrdinalIgnoreCase)) return new JsonResult(new object());
|
if (!id.Equals("Delete", StringComparison.OrdinalIgnoreCase)) return new JsonResult(new object());
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ButtonAuthorize(Url = "~/Admin/Profiles", Auth = "saveIcon")]
|
[ButtonAuthorize(Url = "~/Admin/Profiles", Auth = "saveIcon")]
|
||||||
public async Task<JsonResult> Post([FromServices]IHostingEnvironment env, IFormCollection files)
|
public async Task<JsonResult> Post([FromServices]IWebHostEnvironment env, IFormCollection files)
|
||||||
{
|
{
|
||||||
var previewUrl = string.Empty;
|
var previewUrl = string.Empty;
|
||||||
long fileSize = 0;
|
long fileSize = 0;
|
||||||
|
@ -128,4 +128,4 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,33 @@
|
||||||
using Microsoft.AspNetCore.Authorization;
|
//using Microsoft.AspNetCore.Authorization;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
//using Microsoft.OpenApi.Models;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
//using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using Operation = Swashbuckle.AspNetCore.Swagger.Operation;
|
|
||||||
|
|
||||||
namespace Bootstrap.Admin
|
//namespace Bootstrap.Admin
|
||||||
{
|
//{
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public class HttpHeaderOperation : IOperationFilter
|
// public class HttpHeaderOperation : IOperationFilter
|
||||||
{
|
// {
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="operation"></param>
|
// /// <param name="operation"></param>
|
||||||
/// <param name="context"></param>
|
// /// <param name="context"></param>
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
// public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
{
|
// {
|
||||||
if (operation.Parameters == null) operation.Parameters = new List<IParameter>();
|
// if (operation.Parameters == null) operation.Parameters = new List<OpenApiParameter>();
|
||||||
|
|
||||||
if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Length == 0)
|
// if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Length == 0)
|
||||||
{
|
// {
|
||||||
operation.Parameters.Add(new NonBodyParameter()
|
// operation.Parameters.Add(new OpenApiParameter()
|
||||||
{
|
// {
|
||||||
Name = "Authorization", //添加Authorization头部参数
|
// Name = "Authorization", //添加Authorization头部参数
|
||||||
In = "header",
|
// In = ParameterLocation.Header,
|
||||||
Type = "string",
|
// Required = false
|
||||||
Required = false
|
// });
|
||||||
});
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Bootstrap.Admin.Models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="host"></param>
|
/// <param name="host"></param>
|
||||||
/// <param name="controller"></param>
|
/// <param name="controller"></param>
|
||||||
public ProfilesModel(ControllerBase controller, IHostingEnvironment host) : base(controller)
|
public ProfilesModel(ControllerBase controller, IWebHostEnvironment host) : base(controller)
|
||||||
{
|
{
|
||||||
if (host != null)
|
if (host != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Bootstrap.Admin
|
namespace Bootstrap.Admin
|
||||||
{
|
{
|
||||||
|
@ -14,14 +14,14 @@ namespace Bootstrap.Admin
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
WebHost.CreateDefaultBuilder(args).UseSentry().UseStartup<Startup>();
|
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(builder => builder.UseStartup<Startup>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
using Bootstrap.DataAccess;
|
using Bootstrap.DataAccess;
|
||||||
using Longbow.Web;
|
using Longbow.Web;
|
||||||
using Longbow.Web.SignalR;
|
using Longbow.Web.SignalR;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Versioning;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Newtonsoft.Json;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Unicode;
|
using System.Text.Unicode;
|
||||||
|
@ -43,7 +42,7 @@ namespace Bootstrap.Admin
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
|
//services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
|
||||||
services.Configure<CookiePolicyOptions>(options =>
|
services.Configure<CookiePolicyOptions>(options =>
|
||||||
{
|
{
|
||||||
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
||||||
|
@ -51,39 +50,35 @@ namespace Bootstrap.Admin
|
||||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||||
});
|
});
|
||||||
services.AddCors();
|
services.AddCors();
|
||||||
services.AddLogging(builder => builder.AddFileLogger().AddDBLogger(ExceptionsHelper.Log));
|
//services.AddLogging(builder => builder.AddFileLogger().AddDBLogger(ExceptionsHelper.Log));
|
||||||
services.AddConfigurationManager();
|
services.AddConfigurationManager();
|
||||||
services.AddCacheManager();
|
services.AddCacheManager();
|
||||||
services.AddDbAdapter();
|
services.AddDbAdapter();
|
||||||
services.AddIPLocator(DictHelper.ConfigIPLocator);
|
services.AddIPLocator(DictHelper.ConfigIPLocator);
|
||||||
services.AddOnlineUsers();
|
services.AddOnlineUsers();
|
||||||
services.AddSignalR().AddJsonProtocalDefault();
|
//services.AddSignalR().AddJsonProtocalDefault();
|
||||||
services.AddSignalRExceptionFilterHandler<SignalRHub>((client, ex) => client.SendMessageBody(ex).ConfigureAwait(false));
|
//services.AddSignalRExceptionFilterHandler<SignalRHub>((client, ex) => client.SendMessageBody(ex).ConfigureAwait(false));
|
||||||
services.AddResponseCompression();
|
services.AddResponseCompression();
|
||||||
services.AddBootstrapAdminAuthentication().AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure);
|
services.AddBootstrapAdminAuthentication().AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure);
|
||||||
services.AddSwagger();
|
services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build());
|
||||||
|
//services.AddSwagger();
|
||||||
services.AddButtonAuthorization(MenuHelper.AuthorizateButtons);
|
services.AddButtonAuthorization(MenuHelper.AuthorizateButtons);
|
||||||
services.AddBootstrapAdminBackgroundTask();
|
services.AddBootstrapAdminBackgroundTask();
|
||||||
services.AddHttpClient<GiteeHttpClient>();
|
services.AddHttpClient<GiteeHttpClient>();
|
||||||
services.AddAdminHealthChecks();
|
services.AddAdminHealthChecks();
|
||||||
services.AddMvc(options =>
|
services.AddControllersWithViews(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add<BootstrapAdminAuthorizeFilter>();
|
options.Filters.Add<BootstrapAdminAuthorizeFilter>();
|
||||||
options.Filters.Add<ExceptionFilter>();
|
options.Filters.Add<ExceptionFilter>();
|
||||||
options.Filters.Add<SignalRExceptionFilter<SignalRHub>>();
|
options.Filters.Add<SignalRExceptionFilter<SignalRHub>>();
|
||||||
}).AddJsonOptions(options =>
|
|
||||||
{
|
|
||||||
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
|
||||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
|
||||||
JsonConvert.DefaultSettings = () => options.SerializerSettings;
|
|
||||||
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
|
||||||
services.AddApiVersioning(option =>
|
|
||||||
{
|
|
||||||
option.DefaultApiVersion = new ApiVersion(1, 0);
|
|
||||||
option.ReportApiVersions = true;
|
|
||||||
option.AssumeDefaultVersionWhenUnspecified = true;
|
|
||||||
option.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("api-version"), new QueryStringApiVersionReader("api-version"));
|
|
||||||
});
|
});
|
||||||
|
//services.AddApiVersioning(option =>
|
||||||
|
//{
|
||||||
|
// option.DefaultApiVersion = new ApiVersion(1, 0);
|
||||||
|
// option.ReportApiVersions = true;
|
||||||
|
// option.AssumeDefaultVersionWhenUnspecified = true;
|
||||||
|
// option.ApiVersionReader = ApiVersionReader.Combine(new HeaderApiVersionReader("api-version"), new QueryStringApiVersionReader("api-version"));
|
||||||
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -92,7 +87,7 @@ namespace Bootstrap.Admin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="app"></param>
|
/// <param name="app"></param>
|
||||||
/// <param name="env"></param>
|
/// <param name="env"></param>
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All });
|
app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All });
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
|
@ -109,21 +104,20 @@ namespace Bootstrap.Admin
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseResponseCompression();
|
app.UseResponseCompression();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
app.UseBootstrapAdminAuthentication(RoleHelper.RetrievesByUserName, RoleHelper.RetrievesByUrl, AppHelper.RetrievesByUserName);
|
app.UseBootstrapAdminAuthentication(RoleHelper.RetrievesByUserName, RoleHelper.RetrievesByUrl, AppHelper.RetrievesByUserName);
|
||||||
app.UseBootstrapHealthChecks();
|
app.UseBootstrapHealthChecks();
|
||||||
app.UseOnlineUsers(TraceHelper.Filter, TraceHelper.Save);
|
app.UseOnlineUsers(TraceHelper.Filter, TraceHelper.Save);
|
||||||
app.UseCacheManager();
|
app.UseCacheManager();
|
||||||
app.UseSignalR(routes =>
|
//app.UseSwagger(Configuration["SwaggerPathBase"].TrimEnd('/'));
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
routes.MapHub<SignalRHub>("/NotiHub");
|
//endpoints.MapHub<SignalRHub>("/NotiHub");
|
||||||
routes.MapHub<TaskLogHub>("/TaskLogHub");
|
//endpoints.MapHub<TaskLogHub>("/TaskLogHub");
|
||||||
});
|
//endpoints.MapHealthChecks("/healths");
|
||||||
app.UseSwagger(Configuration["SwaggerPathBase"].TrimEnd('/'));
|
endpoints.MapDefaultControllerRoute().RequireAuthorization();
|
||||||
app.UseMvc(routes =>
|
|
||||||
{
|
|
||||||
routes.MapRoute(
|
|
||||||
name: "default",
|
|
||||||
template: "{controller=Home}/{action=Index}/{id?}");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +1,59 @@
|
||||||
using Microsoft.AspNetCore.Authentication;
|
//using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Builder;
|
//using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
//using Microsoft.Extensions.DependencyInjection;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
//using Microsoft.OpenApi.Models;
|
||||||
using System;
|
//using Swashbuckle.AspNetCore.Swagger;
|
||||||
using System.IO;
|
//using System;
|
||||||
|
//using System.IO;
|
||||||
|
|
||||||
namespace Bootstrap.Admin
|
//namespace Bootstrap.Admin
|
||||||
{
|
//{
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
internal static class SwaggerExtensions
|
// internal static class SwaggerExtensions
|
||||||
{
|
// {
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="app"></param>
|
// /// <param name="app"></param>
|
||||||
/// <param name="pathBase"></param>
|
// /// <param name="pathBase"></param>
|
||||||
public static void UseSwagger(this IApplicationBuilder app, string pathBase)
|
// public static void UseSwagger(this IApplicationBuilder app, string pathBase)
|
||||||
{
|
// {
|
||||||
app.UseWhen(context => context.Request.Path.StartsWithSegments("/swagger"), builder =>
|
// app.UseWhen(context => context.Request.Path.StartsWithSegments("/swagger"), builder =>
|
||||||
{
|
// {
|
||||||
builder.Use(async (context, next) =>
|
// builder.Use(async (context, next) =>
|
||||||
{
|
// {
|
||||||
if (!context.User.Identity.IsAuthenticated) await context.ChallengeAsync();
|
// if (!context.User.Identity.IsAuthenticated) await context.ChallengeAsync();
|
||||||
else await next();
|
// else await next();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
app.UseSwagger();
|
// app.UseSwagger();
|
||||||
app.UseSwaggerUI(c =>
|
// app.UseSwaggerUI(c =>
|
||||||
{
|
// {
|
||||||
c.SwaggerEndpoint($"{pathBase}/swagger/v1/swagger.json", "BootstrapAdmin API V1");
|
// c.SwaggerEndpoint($"{pathBase}/swagger/v1/swagger.json", "BootstrapAdmin API V1");
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="services"></param>
|
// /// <param name="services"></param>
|
||||||
public static void AddSwagger(this IServiceCollection services)
|
// public static void AddSwagger(this IServiceCollection services)
|
||||||
{
|
// {
|
||||||
services.AddSwaggerGen(options =>
|
// services.AddSwaggerGen(options =>
|
||||||
{
|
// {
|
||||||
options.SwaggerDoc("v1", new Info
|
// options.SwaggerDoc("v1", new OpenApiInfo
|
||||||
{
|
// {
|
||||||
Version = "v1",
|
// Version = "v1",
|
||||||
Title = "BootstrapAdmin API"
|
// Title = "BootstrapAdmin API"
|
||||||
});
|
// });
|
||||||
|
|
||||||
//Set the comments path for the swagger json and ui.
|
// //Set the comments path for the swagger json and ui.
|
||||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, "Bootstrap.Admin.xml");
|
// var xmlPath = Path.Combine(AppContext.BaseDirectory, "Bootstrap.Admin.xml");
|
||||||
options.IncludeXmlComments(xmlPath);
|
// options.IncludeXmlComments(xmlPath);
|
||||||
options.OperationFilter<HttpHeaderOperation>(); // 添加httpHeader参数
|
// options.OperationFilter<HttpHeaderOperation>(); // 添加httpHeader参数
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Bootstrap.DataAccess.SqlServer
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Authenticate_Ok()
|
public void Authenticate_Ok()
|
||||||
{
|
{
|
||||||
Assert.True(UserHelper.Authenticate("Admin", "123789", u => u.Ip = "::1"));
|
Assert.True(UserHelper.Authenticate("Admin", "123789"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -27,7 +27,7 @@ namespace Bootstrap.DataAccess.SqlServer
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Authenticate_Fail()
|
public void Authenticate_Fail()
|
||||||
{
|
{
|
||||||
Assert.False(UserHelper.Authenticate("Admin-NotExists", "123789", u => u.Ip = "::1"));
|
Assert.False(UserHelper.Authenticate("Admin-NotExists", "123789"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -11,7 +11,6 @@
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||||
|
|
Loading…
Reference in New Issue