更正:不存在OpenApi授权特性时直接通过授权

This commit is contained in:
2248356998 qq.com
2023-03-06 18:31:04 +08:00
parent ef607036b7
commit e188d4e339
2 changed files with 52 additions and 1 deletions

View File

@@ -66,7 +66,9 @@ namespace ThingsGateway.Web.Core
// 此处已经自动验证 Jwt Verificat的有效性了无需手动验证
// 路由名称
var routeName = httpContext.Request.Path.Value;
if (user.PermissionCodeList?.Contains(routeName) == true)//如果当前路由信息不包含在角色授权路由列表中则认证失败
var isRolePermission = httpContext.GetMetadata<OpenApiPermissionAttribute>();
if (isRolePermission==null||user.PermissionCodeList?.Contains(routeName) == true)//如果当前路由信息不包含在角色授权路由列表中则认证失败
return true;
else
return false;

View File

@@ -0,0 +1,49 @@
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NewLife;
using System.Linq;
using ThingsGateway.Core;
using ThingsGateway.Core.Extension;
namespace ThingsGateway.Web.Foundation
{
/// <summary>
/// 采集设备
/// </summary>
[ApiDescriptionSettings(CateGoryConst.ThingsGatewayOpenApi, Order = 200)]
[Route("openApi/collectdbInfo")]
[Description("获取配置信息")]
[LoggingMonitor]
[Authorize(AuthenticationSchemes = "Bearer")]
public class CollectDbInfoControler : IDynamicApiController
{
IServiceScopeFactory _scopeFactory;
IVariableService _variableService { get; set; }
public CollectDbInfoControler(IServiceScopeFactory scopeFactory,IVariableService variableService)
{
_scopeFactory = scopeFactory;
_variableService = variableService;
}
/// <summary>
/// 获取变量信息
/// </summary>
/// <returns></returns>
[HttpGet("variableList")]
[Description("获取变量信息")]
public async Task<SqlSugarPagedList<CollectDeviceVariable>> GetVariableList([FromQuery] VariablePageInput input)
{
var data = await _variableService.Page(input);
return data;
}
}
}