Browse Source

差真权限处理

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

3
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.DbMigrator/appsettings.json

@ -1,6 +1,7 @@
{ {
"ConnectionStrings": { "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": { "OpenIddict": {
"Applications": { "Applications": {

4
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Properties/launchSettings.json

@ -3,7 +3,7 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "https://localhost:60069/", "applicationUrl": "http://localhost:60069/",
"sslPort": 44392 "sslPort": 44392
} }
}, },
@ -21,7 +21,7 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"applicationUrl": "https://localhost:60069/" "applicationUrl": "http://localhost:60069/"
} }
} }
} }

49
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/WininWebModule.cs

@ -46,6 +46,9 @@ using Polly;
using Autofac.Core; using Autofac.Core;
using Faster.Zheng.Winin.AppBusiness.TestSchool; using Faster.Zheng.Winin.AppBusiness.TestSchool;
using static Faster.Zheng.Winin.Web.WininWebAutoMapperProfile; using static Faster.Zheng.Winin.Web.WininWebAutoMapperProfile;
using System.Reflection.Metadata;
using Microsoft.AspNetCore.Antiforgery;
using Microsoft.AspNetCore.Http;
namespace Faster.Zheng.Winin.Web; namespace Faster.Zheng.Winin.Web;
@ -87,8 +90,12 @@ public class WininWebModule : AbpModule
options.UseAspNetCore(); options.UseAspNetCore();
}); });
}); });
//SetNoHttps(context);
} }
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
@ -243,6 +250,31 @@ public class WininWebModule : AbpModule
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Winin API"); 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 => //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 #endregion
} }

34
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/appsettings.json

@ -1,19 +1,45 @@
{ {
"App": { "App": {
"SelfUrl": "https://localhost:60069", "SelfUrl": "http://localhost:60069",
// //
"CorsOrigins": [ "CorsOrigins": [
"http://localhost:9527", "http://localhost:9527",
"http://localhost:9528" "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": { "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;" "Default": "Server=dev.ccwin-in.com,13319;Database=Faster.Zheng.Winin;uid=ccwin-in;pwd=Microsoft@2022;timeout=6000;Encrypt=False;"
}, },
"StringEncryption": { "StringEncryption": {
"DefaultPassPhrase": "Aj66rJI3krHbVhS6" "DefaultPassPhrase": "Aj66rJI3krHbVhS6"
}, },
"AlwaysAllowAuthorization": "True", "AlwaysAllowAuthorization": "True",
"urls": "https://localhost:60069" "urls": "http://localhost:60069"
} }

Loading…
Cancel
Save