Browse Source

差真权限处理

master
boxu.zheng 1 year ago
parent
commit
39577d5482
  1. 5
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs
  2. 3
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.DbMigrator/appsettings.json
  3. 4
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Properties/launchSettings.json
  4. 51
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/WininWebModule.cs
  5. 34
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/appsettings.json

5
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs

@ -33,8 +33,6 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
where TEntityDto : IEntityDto<TKey>
{
private readonly IRepository<TEntity, TKey> _repository;
private readonly IMapper _mapper;
private Func<TCreateInput, Entity> _mapFunc;
protected IStringLocalizer<WininResource> _localizer =>
LazyServiceProvider.LazyGetRequiredService<IStringLocalizer<WininResource>>();
@ -42,7 +40,6 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
protected ExportCustomUserSettingAppService _exportCustomUserSettingAppService =>
LazyServiceProvider.LazyGetRequiredService<ExportCustomUserSettingAppService>();
public ZbxBase(IRepository<TEntity, TKey> repository) : base(repository)
{
_repository = repository;
@ -61,6 +58,8 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
public async Task<PagedResultDto<TEntityDto>> GetPageListByFilterAsync(SfsRequestInputBase sfsRequestInputBase,
bool includeDetails = false, CancellationToken cancellationToken = default)
{
await CheckGetListPolicyAsync();
var expression = sfsRequestInputBase.Condition.Filters?.Count > 0
? sfsRequestInputBase.Condition.Filters.ToLambda<TEntity>()
: p => true;

3
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": {

4
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/"
}
}
}

51
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<IAntiforgery>();
//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
});
}
/// <summary>
/// 解决获取token时如果是http不是https造成的无法获取
/// </summary>
/// <param name="context"></param>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
}

34
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"
}

Loading…
Cancel
Save