Skip to content

Commit

Permalink
Merge pull request #933 from colinin/rel-8.0.3
Browse files Browse the repository at this point in the history
upgrade abp framework to 8.0.4
  • Loading branch information
colinin committed Apr 13, 2024
2 parents 741ef9f + 338ddec commit e52987e
Show file tree
Hide file tree
Showing 45 changed files with 4,036 additions and 3,695 deletions.
7 changes: 6 additions & 1 deletion apps/vue/src/store/modules/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { AppRouteRecordRaw, Menu, RouteMeta } from '/@/router/types';
import { defineStore } from 'pinia';
import { store } from '/@/store';
import { useI18n } from '/@/hooks/web/useI18n';
import { useLocalization } from '/@/hooks/abp/useLocalization';
import { useLocalizationSerializer } from '/@/hooks/abp/useLocalizationSerializer';
import { useUserStore } from './user';
import { useAbpStoreWithOut } from './abp';
import { useAppStoreWithOut } from './app';
Expand Down Expand Up @@ -223,19 +225,22 @@ export const usePermissionStore = defineStore({
return routes;
},
filterDynamicRoutes(menus: RouteItem[]) {
const { deserialize } = useLocalizationSerializer();
const { Lr } = useLocalization();
const routeList: AppRouteRecordRaw[] = [];
menus.forEach((menu) => {
if (!this.validationFeatures(menu.meta)) {
return;
}
const titleInfo = deserialize(menu.meta.title);
const r: AppRouteRecordRaw = {
path: menu.path,
name: menu.name!,
redirect: menu.redirect,
component: menu.component,
meta: {
affix: mapMetaBoolean('affix', menu.meta),
title: menu.meta.title,
title: Lr(titleInfo.resourceName, titleInfo.name),
icon: menu.meta.icon,
ignoreAuth: mapMetaBoolean('ignoreAuth', menu.meta),
ignoreKeepAlive: mapMetaBoolean('ignoreKeepAlive', menu.meta),
Expand Down
4 changes: 2 additions & 2 deletions aspnet-core/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<VoloAbpPackageVersion>8.0.3</VoloAbpPackageVersion>
<VoloAbpPackageVersion>8.0.4</VoloAbpPackageVersion>
<VoloAbpLeptonXThemePackageVersion>3.0.0</VoloAbpLeptonXThemePackageVersion>
<LINGYUNAbpPackageVersion>8.0.3</LINGYUNAbpPackageVersion>
<LINGYUNAbpPackageVersion>8.0.4</LINGYUNAbpPackageVersion>
<DaprPackageVersion>1.12.0</DaprPackageVersion>
<DistributedLockRedisPackageVersion>1.0.2</DistributedLockRedisPackageVersion>
<DotNetCoreCAPPackageVersion>8.0.0</DotNetCoreCAPPackageVersion>
Expand Down
2 changes: 1 addition & 1 deletion aspnet-core/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>8.0.3</Version>
<Version>8.0.4</Version>
<Authors>colin</Authors>
<NoWarn>$(NoWarn);CS1591;CS0436;CS8618;NU1803</NoWarn>
<PackageProjectUrl>https://github.com/colinin/abp-next-admin</PackageProjectUrl>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@

<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="appsettings.Production.json" />
</ItemGroup>

<ItemGroup>
<Content Include="appsettings.Production.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Content;

namespace LINGYUN.Abp.OssManagement
{
public interface IShareFileAppService : IApplicationService
{
Task<GetFileShareDto> GetAsync(string url);
Task<IRemoteStreamContent> GetAsync(string url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async virtual Task UploadAsync(UploadFileChunkInput input, CancellationTo
catch
{
// 发生异常删除临时文件目录
Directory.Delete(tempFilePath, true);
DirectoryHelper.DeleteIfExists(tempFilePath, true);
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using LINGYUN.Abp.OssManagement.Features;
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.Content;
using Volo.Abp.Http;

namespace LINGYUN.Abp.OssManagement
{
Expand All @@ -23,17 +26,17 @@ public ShareFileAppService(
_ossContainerFactory = ossContainerFactory;
}

public async virtual Task<GetFileShareDto> GetAsync(string url)
public async virtual Task<IRemoteStreamContent> GetAsync(string url)
{
if (!await FeatureChecker.IsEnabledAsync(AbpOssManagementFeatureNames.OssObject.AllowSharedFile))
{
return new GetFileShareDto(url);
return new RemoteStreamContent(Stream.Null);
}
var cacheKey = FileShareCacheItem.CalculateCacheKey(url);
var cacheItem = await _shareCache.GetAsync(cacheKey);
if (cacheItem == null)
{
return new GetFileShareDto(url);
return new RemoteStreamContent(Stream.Null);
}

// 最大访问次数
Expand All @@ -46,15 +49,15 @@ public async virtual Task<GetFileShareDto> GetAsync(string url)
{
await _shareCache.RemoveAsync(cacheKey);

return new GetFileShareDto(url);
return new RemoteStreamContent(Stream.Null);
}

// 共享用户
if (cacheItem.Users != null && cacheItem.Users.Any())
{
if (cacheItem.Users.Any((userName) => !userName.Equals(CurrentUser.UserName)))
{
return new GetFileShareDto(url);
return new RemoteStreamContent(Stream.Null);
}
}

Expand All @@ -63,7 +66,7 @@ public async virtual Task<GetFileShareDto> GetAsync(string url)
{
if (cacheItem.Roles.Any((role) => !CurrentUser.Roles.Contains(role)))
{
return new GetFileShareDto(url);
return new RemoteStreamContent(Stream.Null);
}
}

Expand All @@ -90,7 +93,7 @@ await _shareCache.SetAsync(
cacheItem,
cacheOptions);

return new GetFileShareDto(ossObject.Name, ossObject.Content);
return new RemoteStreamContent(ossObject.Content, ossObject.Name, MimeTypes.GetByExtension(ossObject.Name), ossObject.Size);
}

protected async virtual Task RefreshUserShareAsync(FileShareCacheItem shareCacheItem)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
using LINGYUN.Abp.OssManagement.Localization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Http;
using Volo.Abp.Content;

namespace LINGYUN.Abp.OssManagement
{
[Area("oss-management")]
[Route("api/files/share")]
[RemoteService(false)]
[ApiExplorerSettings(IgnoreApi = true)]
public class ShareFilesController : AbpController
public class ShareFilesController : AbpController, IShareFileAppService
{
private readonly IShareFileAppService _service;

Expand All @@ -28,16 +25,9 @@ public ShareFilesController(

[HttpGet]
[Route("{url}")]
public async virtual Task<IActionResult> GetAsync(string url)
public virtual Task<IRemoteStreamContent> GetAsync(string url)
{
var ossObject = await _service.GetAsync(url);

if (ossObject.Content.IsNullOrEmpty())
{
return NotFound();
}

return File(ossObject.Content, MimeTypes.GetByExtension(Path.GetExtension(ossObject.Name)));
return _service.GetAsync(url);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,14 @@ private static NavigationDefinition GetManage()

var removedIdsVersion = false;
var assembly = typeof(AbpUINavigationVueVbenAdminNavigationDefinitionProvider).Assembly;
var versionAttr = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
var versionAttr = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>();
if (versionAttr != null)
{
var version = new Version(versionAttr.InformationalVersion);
var version6 = new Version("6.0.0");
removedIdsVersion = version6 >= version;
if (Version.TryParse(versionAttr.Version, out var version))
{
var version6 = new Version("6.0.0");
removedIdsVersion = version6 >= version;
}
}

if (!removedIdsVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
using Volo.Abp.OpenIddict;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Quartz;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement;
using Volo.Abp.TextTemplating;
using Volo.Abp.Threading;
Expand Down Expand Up @@ -616,6 +617,10 @@ private void ConfigureIdentity(IConfiguration configuration)
identityConfiguration.Bind(options);
}
});
Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
});
}

private void ConfigureMvcUiTheme()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using Volo.Abp.MultiTenancy;
using Volo.Abp.OpenIddict.Localization;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Security.Claims;
using Volo.Abp.Threading;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem;
Expand Down Expand Up @@ -272,6 +273,14 @@ private void ConfigureMultiTenancy(IConfiguration configuration)
}
}

private void ConfigureIdentity()
{
Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
});
}

private void ConfigureSwagger(IServiceCollection services)
{
// Swagger
Expand Down Expand Up @@ -362,6 +371,7 @@ private void ConfigureSecurity(IServiceCollection services, IConfiguration confi
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.Audience = configuration["AuthServer:ApiName"];
options.MapInboundClaims = false;
});

if (isDevelopment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();

ConfigureIdentity();
ConfigureDbContext();
ConfigureLocalization();
ConfigreExceptionHandling();
Expand Down Expand Up @@ -113,9 +114,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseCors(DefaultCorsPolicyName);
// 认证
app.UseAuthentication();
// IDS与JWT不匹配可能造成鉴权错误
// TODO: abp在某个更新版本建议移除此中间价
app.UseAbpClaimsMap();
app.UseDynamicClaims();
// 多租户
app.UseMultiTenancy();
// 授权
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem;
using Microsoft.IdentityModel.Logging;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement;
using Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims;

namespace LY.MicroService.BackendAdmin;

Expand Down Expand Up @@ -141,12 +145,21 @@ private void ConfigurePermissionManagement()
{
Configure<PermissionManagementOptions>(options =>
{
options.IsDynamicPermissionStoreEnabled = true;
// Rename IdentityServer.Client.ManagePermissions
// See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs
options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = "AbpIdentityServer.Clients.ManagePermissions";
});
}

private void ConfigureSettingManagement()
{
Configure<SettingManagementOptions>(options =>
{
options.IsDynamicSettingStoreEnabled = true;
});
}

private void ConfigureExceptionHandling()
{
// 自定义需要处理的异常
Expand Down Expand Up @@ -234,6 +247,15 @@ private void ConfigureMultiTenancy(IConfiguration configuration)
}
}

private void ConfigureIdentity(IConfiguration configuration)
{
Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
options.RemoteRefreshUrl = configuration["AuthServerUrl"] + options.RemoteRefreshUrl;
});
}

private void ConfigureAuditing(IConfiguration configuration)
{
Configure<AbpAuditingOptions>(options =>
Expand Down Expand Up @@ -352,6 +374,7 @@ private void ConfigureSecurity(IServiceCollection services, IConfiguration confi
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.Audience = configuration["AuthServer:ApiName"];
options.MapInboundClaims = false;
});

if (isDevelopment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ public override void ConfigureServices(ServiceConfigurationContext context)
ConfigureExceptionHandling();
ConfigureVirtualFileSystem();
ConfigureTextTemplating();
ConfigureSettingManagement();
ConfigureFeatureManagement();
ConfigurePermissionManagement();
ConfigureIdentity(configuration);
ConfigureCaching(configuration);
ConfigureAuditing(configuration);
ConfigureSwagger(context.Services);
Expand All @@ -146,11 +148,8 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseCors(DefaultCorsPolicyName);
// 认证
app.UseAuthentication();
// IDS与JWT不匹配可能造成鉴权错误
// TODO: abp在某个更新版本建议移除此中间价
app.UseAbpClaimsMap();
// jwt
app.UseJwtTokenMiddleware();
app.UseDynamicClaims();
// 多租户
app.UseMultiTenancy();
// 授权
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"CorsOrigins": "http://127.0.0.1:3100",
"ShowPii": true
},
"AuthServerUrl": "http://127.0.0.1:30015",
"Auditing": {
"AllEntitiesSelector": true
},
Expand Down
Loading

0 comments on commit e52987e

Please sign in to comment.