From 39577d5482b0371c098e57bcddc27c578b6fe7aa Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Tue, 11 Jul 2023 14:55:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=AE=E7=9C=9F=E6=9D=83=E9=99=90=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppBase/ZbxBase.cs | 5 +- .../appsettings.json | 3 +- .../Properties/launchSettings.json | 4 +- .../Faster.Zheng.Winin.Web/WininWebModule.cs | 51 ++++++++++++++++++- .../Faster.Zheng.Winin.Web/appsettings.json | 34 +++++++++++-- 5 files changed, 86 insertions(+), 11 deletions(-) diff --git a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs index 55fb94d..886dbde 100644 --- a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs +++ b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs @@ -33,8 +33,6 @@ public class ZbxBase { private readonly IRepository _repository; - private readonly IMapper _mapper; - private Func _mapFunc; protected IStringLocalizer _localizer => LazyServiceProvider.LazyGetRequiredService>(); @@ -42,7 +40,6 @@ public class ZbxBase LazyServiceProvider.LazyGetRequiredService(); - public ZbxBase(IRepository repository) : base(repository) { _repository = repository; @@ -61,6 +58,8 @@ public class ZbxBase> GetPageListByFilterAsync(SfsRequestInputBase sfsRequestInputBase, bool includeDetails = false, CancellationToken cancellationToken = default) { + await CheckGetListPolicyAsync(); + var expression = sfsRequestInputBase.Condition.Filters?.Count > 0 ? sfsRequestInputBase.Condition.Filters.ToLambda() : p => true; diff --git a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.DbMigrator/appsettings.json b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.DbMigrator/appsettings.json index dca69af..7275b79 100644 --- a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.DbMigrator/appsettings.json +++ b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.DbMigrator/appsettings.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "Default": "Server=.;Database=Faster.Zheng.Winin;uid=sa;pwd=sasa;timeout=6000;Encrypt=False" + //"Default": "Server=.;Database=Faster.Zheng.Winin;uid=sa;pwd=sasa;timeout=6000;Encrypt=False", + "Default": "Server=dev.ccwin-in.com,13319;Database=Faster.Zheng.Winin;uid=ccwin-in;pwd=Microsoft@2022;timeout=6000;Encrypt=False;" }, "OpenIddict": { "Applications": { diff --git a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Properties/launchSettings.json b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Properties/launchSettings.json index fed2596..9b18541 100644 --- a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Properties/launchSettings.json +++ b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "https://localhost:60069/", + "applicationUrl": "http://localhost:60069/", "sslPort": 44392 } }, @@ -21,7 +21,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:60069/" + "applicationUrl": "http://localhost:60069/" } } } \ No newline at end of file diff --git a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/WininWebModule.cs b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/WininWebModule.cs index 1ad24d3..7f7d972 100644 --- a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/WininWebModule.cs +++ b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/WininWebModule.cs @@ -46,6 +46,9 @@ using Polly; using Autofac.Core; using Faster.Zheng.Winin.AppBusiness.TestSchool; using static Faster.Zheng.Winin.Web.WininWebAutoMapperProfile; +using System.Reflection.Metadata; +using Microsoft.AspNetCore.Antiforgery; +using Microsoft.AspNetCore.Http; namespace Faster.Zheng.Winin.Web; @@ -87,8 +90,12 @@ public class WininWebModule : AbpModule options.UseAspNetCore(); }); }); + + //SetNoHttps(context); } + + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -243,7 +250,32 @@ public class WininWebModule : AbpModule options.SwaggerEndpoint("/swagger/v1/swagger.json", "Winin API"); }); - + #region 解决权限问题 搁置 + + //var antiforgery = app.ApplicationServices.GetRequiredService(); + + //app.Use((context, next) => + //{ + // var requestPath = context.Request.Path.Value; + + // if (string.Equals(requestPath, "/", StringComparison.OrdinalIgnoreCase) + // || string.Equals(requestPath, "/index.html", StringComparison.OrdinalIgnoreCase)) + // { + // var tokenSet = antiforgery.GetAndStoreTokens(context); + // context.Response.Cookies.Append("XSRF-TOKEN", tokenSet.RequestToken!, + // new CookieOptions { HttpOnly = false }); + // } + + // return next(context); + //}); + + #endregion + + + + + + //app.UseAbpSwaggerUI(options => //{ @@ -318,5 +350,22 @@ public class WininWebModule : AbpModule }); } + /// + /// 解决获取token时如果是http不是https造成的无法获取 + /// + /// mo + private void SetNoHttps(ServiceConfigurationContext context) + { + context.Services.AddOpenIddict() + .AddServer(option => + { + option.AllowCustomFlow("urn:m2i:params:oauth:grant-type:impersonate_user"); + + option.SetTokenEndpointUris(new[] { "/connect/token" }); + + option.UseAspNetCore().DisableTransportSecurityRequirement(); + }); + } + #endregion } diff --git a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/appsettings.json b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/appsettings.json index 4a47863..4ddfb92 100644 --- a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/appsettings.json +++ b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/appsettings.json @@ -1,19 +1,45 @@ { "App": { - "SelfUrl": "https://localhost:60069", + "SelfUrl": "http://localhost:60069", //璺ㄥ煙 "CorsOrigins": [ "http://localhost:9527", "http://localhost:9528" ] }, + //"OpenIddict": { + // "Applications": { + // "Winin_Web": { + // "ClientId": "Winin_Web", + // "ClientSecret": "1q2w3e*", + // "RootUrl": "http://localhost:44399", + // "RequireHttpsMetadata": "false" + // }, + // "Winin_App": { + // "ClientId": "Winin_App", + // "RootUrl": "http://localhost:4200", + // "RequireHttpsMetadata": "false" + // }, + // "Winin_BlazorServerTiered": { + // "ClientId": "Winin_BlazorServerTiered", + // "ClientSecret": "1q2w3e*", + // "RootUrl": "http://localhost:44392", + // "RequireHttpsMetadata": "false" + // }, + // "Winin_Swagger": { + // "ClientId": "Winin_Swagger", + // "RootUrl": "http://localhost:44355", + // "RequireHttpsMetadata": "false" + // } + // } + //}, "ConnectionStrings": { - "Default": "Server=.;Database=Faster.Zheng.Winin;uid=sa;pwd=sasa;timeout=6000;Encrypt=False" - //"Default": "Server=dev.ccwin-in.com,13319;Database=Faster.Zheng.Winin;uid=ccwin-in;pwd=Microsoft@2022;timeout=6000;Encrypt=False;" + //"Default": "Server=.;Database=Faster.Zheng.Winin;uid=sa;pwd=sasa;timeout=6000;Encrypt=False" + "Default": "Server=dev.ccwin-in.com,13319;Database=Faster.Zheng.Winin;uid=ccwin-in;pwd=Microsoft@2022;timeout=6000;Encrypt=False;" }, "StringEncryption": { "DefaultPassPhrase": "Aj66rJI3krHbVhS6" }, "AlwaysAllowAuthorization": "True", - "urls": "https://localhost:60069" + "urls": "http://localhost:60069" }