Hi,
Could you use the abp suite to create a new project to reproduce the problem and share it with me? my email is shiwei.liang@volosoft.com.
I will check it. thanks.
Hi,
We will check it.
Hi,
Could you share a project with me? I will check it. thanks shiwei.liang@volosoft.com
Hi,
Yes.
I want to set permissions dynamically according to creating menu items.
You need to implement it yourself.
But you can't add permissions dynamically, you can consider creating your own menu permission table and check menu permissions in the middleware
Your ticket was refunded
Hi
I can confirm the problem, we will fix it in the next patch version.
This is a temporary solution:
[Serializable]
[IgnoreMultiTenancy]
public class MyFileDownloadTokenCacheItem
{
public Guid FileDescriptorId { get; set; }
public Guid? TenantId { get; set; }
}
[RequiresFeature(FileManagementFeatures.Enable)]
[Authorize(FileManagementPermissions.FileDescriptor.Default)]
[ExposeServices(typeof(IFileDescriptorAppService))]
public class MyFileDescriptorAppService : FileDescriptorAppService
{
private IDistributedCache<MyFileDownloadTokenCacheItem, string> _tokenCache { get; set; }
public MyFileDescriptorAppService(IFileManager fileManager, IFileDescriptorRepository fileDescriptorRepository,
IBlobContainer<FileManagementContainer> blobContainer,
IDistributedCache<FileDownloadTokenCacheItem, string> downloadTokenCache,
IDistributedCache<MyFileDownloadTokenCacheItem, string> tokenCache) : base(fileManager,
fileDescriptorRepository, blobContainer, downloadTokenCache)
{
_tokenCache = tokenCache;
}
[AllowAnonymous]
public override async Task<IRemoteStreamContent> DownloadAsync(Guid id, string token)
{
var downloadToken = await _tokenCache.GetAsync(token);
if (downloadToken == null || downloadToken.FileDescriptorId != id)
{
throw new AbpAuthorizationException("Invalid download token: " + token);
}
using (CurrentTenant.Change(downloadToken.TenantId))
{
var fileDescriptor = await FileDescriptorRepository.GetAsync(id);
var stream = await BlobContainer.GetAsync(id.ToString());
return new RemoteStreamContent(stream, fileDescriptor?.Name);
}
}
public override async Task<DownloadTokenResultDto> GetDownloadTokenAsync(Guid id)
{
var token = Guid.NewGuid().ToString();
await _tokenCache.SetAsync(
token,
new MyFileDownloadTokenCacheItem()
{
FileDescriptorId = id,
TenantId = CurrentTenant.Id
},
new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(60)
});
return new DownloadTokenResultDto
{
Token = token
};
}
}