fix #I3RHPD 在api中对用户接口权限进行鉴权

This commit is contained in:
yubaolee
2025-03-11 11:21:56 +08:00
parent 50769b94c6
commit 18c6fbfaad
4 changed files with 64 additions and 14 deletions

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Threading.Tasks;
using Infrastructure;
using NUnit.Framework;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
@@ -105,6 +107,18 @@ namespace OpenAuth.App
return result;
}
/// <summary>
/// 获取资源类型
/// </summary>
/// <returns></returns>
public async Task<List<SysResourceApp>> GetResourceApps()
{
var types = await SugarClient.Queryable<SysResource>()
.Distinct()
.Select(u => new {u.AppId,u.AppName})
.ToListAsync();
return types.Select(u => new SysResourceApp(u.AppId, u.AppName)).ToList();
}
/// <summary>
/// 同步站点API到资源列表
/// <para>读取站点API信息如果资源列表中不存在则添加</para>
@@ -124,9 +138,12 @@ namespace OpenAuth.App
resource = new SysResource
{
Id = api.Path,
Name = api.Path,
Disable = true,
SortNo = 0,
AppId = $"{Define.API}_{api.Tag}",
AppName = $"API接口-{api.Tag}",
TypeId = Define.API,
TypeName = "API接口",
Description = api.Summary??"",
@@ -140,4 +157,9 @@ namespace OpenAuth.App
}
}
/// <summary>
/// 资源类型
/// </summary>
public record SysResourceApp(string Id, string Name);
}