Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/NewLifeX/NewLife.Cube
Browse files Browse the repository at this point in the history
  • Loading branch information
QinKeping committed May 29, 2024
2 parents 52e84a1 + 7e7e5c9 commit 49eab16
Show file tree
Hide file tree
Showing 30 changed files with 1,297 additions and 190 deletions.
4 changes: 2 additions & 2 deletions CubeDemo/CubeDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.5" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2024.417-beta1339" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions CubeDemoNC/CubeDemoNC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.4" />
<PackageReference Include="NewLife.Redis.Extensions" Version="5.5.2024.411-beta0755" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.5" />
<PackageReference Include="NewLife.Redis.Extensions" Version="5.5.2024.508" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2024.417-beta1339" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion CubeSSO/CubeSSO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.9.2024.417-beta1447" />
<PackageReference Include="NewLife.Core" Version="10.10.2024.507" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2024.417-beta1339" />
</ItemGroup>

Expand Down
Binary file added Doc/安全访问架构.emmx
Binary file not shown.
Binary file added Doc/安全访问架构.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion NewLife.Cube.Blazor/NewLife.Cube.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="8.4.7" />
<PackageReference Include="BootstrapBlazor" Version="8.5.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
19 changes: 19 additions & 0 deletions NewLife.Cube/Areas/Admin/Controllers/AccessRuleController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.ComponentModel;
using NewLife.Cube.Entity;
using XCode.Membership;

namespace NewLife.Cube.Areas.Admin.Controllers;

/// <summary>访问规则</summary>
[DisplayName("访问规则")]
[AdminArea]
[Menu(0, false, Icon = "fa-star")]
public class AccessRuleController : EntityController<AccessRule>
{
static AccessRuleController()
{
LogOnChange = true;

ListFields.RemoveCreateField().RemoveRemarkField();
}
}
9 changes: 6 additions & 3 deletions NewLife.Cube/Common/ReadOnlyEntityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,11 @@ protected virtual WhereBuilder CreateWhere()

/// <summary>多次导出数据</summary>
/// <returns></returns>
protected virtual IEnumerable<TEntity> ExportData(Int32 max = 10_000_000)
protected virtual IEnumerable<TEntity> ExportData(Int32 max = 0)
{
var set = CubeSetting.Current;
if (max <= 0) max = set.MaxExport;

// 计算目标数据量
var p = Session[CacheKey] as Pager;
p = new Pager(p)
Expand Down Expand Up @@ -325,7 +328,7 @@ protected virtual IEnumerable<TEntity> ExportData(Int32 max = 10_000_000)

/// <summary>分页导出数据</summary>
/// <param name="pageSize">页大小。默认10_000</param>
/// <param name="max">最大行数。默认10_000_000</param>
/// <param name="max">最大行数</param>
/// <returns></returns>
protected virtual IEnumerable<TEntity> ExportDataByPage(Int32 pageSize, Int32 max)
{
Expand Down Expand Up @@ -366,7 +369,7 @@ protected virtual IEnumerable<TEntity> ExportDataByPage(Int32 pageSize, Int32 ma

/// <summary>时间分片导出数据</summary>
/// <param name="step">分片不仅。默认60</param>
/// <param name="max">最大行数。默认10_000_000</param>
/// <param name="max">最大行数</param>
/// <returns></returns>
protected virtual IEnumerable<TEntity> ExportDataByDatetime(Int32 step, Int32 max)
{
Expand Down
3 changes: 2 additions & 1 deletion NewLife.Cube/CubeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ public static IServiceCollection AddCube(this IServiceCollection services)
//默认注入缓存实现
services.TryAddSingleton<ICacheProvider, CacheProvider>();

// UI服务
// 服务
services.AddSingleton<PasswordService>();
services.AddSingleton<UserService>();
services.AddSingleton<AccessService>();

//services.AddHostedService<JobService>();
services.AddHostedService<DataRetentionService>();
Expand Down
248 changes: 248 additions & 0 deletions NewLife.Cube/Entity/Cube.htm
Original file line number Diff line number Diff line change
Expand Up @@ -3666,3 +3666,251 @@ <h3>指令管理(OrderManager)</h3>
</tbody>
</table>
<br></br>
<h3>访问规则(AccessRule)</h3>
<table>
<thead>
<tr>
<th>名称</th>
<th>显示名</th>
<th>类型</th>
<th>长度</th>
<th>精度</th>
<th>主键</th>
<th>允许空</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>Id</td>
<td>编号</td>
<td>Int32</td>
<td></td>
<td></td>
<td title="自增">AI</td>
<td>N</td>
<td></td>
</tr>

<tr>
<td>Name</td>
<td>名称</td>
<td>String</td>
<td>50</td>
<td></td>
<td title="唯一索引">UQ</td>
<td>N</td>
<td></td>
</tr>

<tr>
<td>Enable</td>
<td>启用</td>
<td>Boolean</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td></td>
</tr>

<tr>
<td>Priority</td>
<td>优先级</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>较大优先</td>
</tr>

<tr>
<td>Url</td>
<td>URL路径</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td>支持*模糊匹配,多个逗号隔开</td>
</tr>

<tr>
<td>UserAgent</td>
<td>用户代理</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td>支持*模糊匹配,多个逗号隔开</td>
</tr>

<tr>
<td>IP</td>
<td>来源IP</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td>支持*模糊匹配,多个逗号隔开</td>
</tr>

<tr>
<td>LoginedUser</td>
<td>登录用户</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td>支持*模糊匹配,多个逗号隔开</td>
</tr>

<tr>
<td>ActionKind</td>
<td>动作</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>放行/拦截/限流</td>
</tr>

<tr>
<td>BlockCode</td>
<td>拦截代码</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>拦截时返回Http代码,如404/500/302等</td>
</tr>

<tr>
<td>BlockContent</td>
<td>拦截内容</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td>拦截时返回内容,返回302时此处调目标地址</td>
</tr>

<tr>
<td>LimitDimension</td>
<td>限流维度</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>IP/用户</td>
</tr>

<tr>
<td>LimitCycle</td>
<td>限流时间</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>限流时的考察时间,期间累加规则触发次数,如600秒</td>
</tr>

<tr>
<td>LimitTimes</td>
<td>限流次数</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>限流考察期间达到该阈值时,执行拦截</td>
</tr>

<tr>
<td>CreateUserID</td>
<td>创建者</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td></td>
</tr>

<tr>
<td>CreateTime</td>
<td>创建时间</td>
<td>DateTime</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

<tr>
<td>CreateIP</td>
<td>创建地址</td>
<td>String</td>
<td>50</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

<tr>
<td>UpdateUserID</td>
<td>更新者</td>
<td>Int32</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td></td>
</tr>

<tr>
<td>UpdateTime</td>
<td>更新时间</td>
<td>DateTime</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

<tr>
<td>UpdateIP</td>
<td>更新地址</td>
<td>String</td>
<td>50</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

<tr>
<td>Remark</td>
<td>内容</td>
<td>String</td>
<td>500</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<br></br>
28 changes: 28 additions & 0 deletions NewLife.Cube/Entity/Cube.xml
Original file line number Diff line number Diff line change
Expand Up @@ -460,5 +460,33 @@
<Index Columns="Code" Unique="True" />
</Indexes>
</Table>
<Table Name="AccessRule" Description="访问规则。控制系统访问的安全访问规则,放行或拦截或限流">
<Columns>
<Column Name="Id" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
<Column Name="Name" DataType="String" Master="True" Nullable="False" Description="名称" />
<Column Name="Enable" DataType="Boolean" Description="启用" />
<Column Name="Priority" DataType="Int32" Description="优先级。较大优先" />
<Column Name="Url" DataType="String" Length="500" Description="URL路径。支持*模糊匹配,多个逗号隔开" />
<Column Name="UserAgent" DataType="String" Length="500" Description="用户代理。支持*模糊匹配,多个逗号隔开" />
<Column Name="IP" DataType="String" Length="500" Description="来源IP。支持*模糊匹配,多个逗号隔开" />
<Column Name="LoginedUser" DataType="String" Length="500" Description="登录用户。支持*模糊匹配,多个逗号隔开" />
<Column Name="ActionKind" DataType="Int32" Description="动作。放行/拦截/限流" Type="AccessActionKinds" />
<Column Name="BlockCode" DataType="Int32" Description="拦截代码。拦截时返回Http代码,如404/500/302等" />
<Column Name="BlockContent" DataType="String" Length="500" Description="拦截内容。拦截时返回内容,返回302时此处调目标地址" />
<Column Name="LimitDimension" DataType="Int32" Description="限流维度。IP/用户" Type="LimitDimensions" />
<Column Name="LimitCycle" DataType="Int32" ItemType="TimeSpan" Description="限流时间。限流时的考察时间,期间累加规则触发次数,如600秒" />
<Column Name="LimitTimes" DataType="Int32" Description="限流次数。限流考察期间达到该阈值时,执行拦截" />
<Column Name="CreateUserID" DataType="Int32" Description="创建者" Category="扩展" />
<Column Name="CreateTime" DataType="DateTime" Description="创建时间" Category="扩展" />
<Column Name="CreateIP" DataType="String" Description="创建地址" Category="扩展" />
<Column Name="UpdateUserID" DataType="Int32" Description="更新者" Category="扩展" />
<Column Name="UpdateTime" DataType="DateTime" Description="更新时间" Category="扩展" />
<Column Name="UpdateIP" DataType="String" Description="更新地址" Category="扩展" />
<Column Name="Remark" DataType="String" Length="500" Description="内容" Category="扩展" />
</Columns>
<Indexes>
<Index Columns="Name" Unique="True" />
</Indexes>
</Table>
</Tables>
</EntityModel>
Loading

0 comments on commit 49eab16

Please sign in to comment.