committed by
GitHub
102 changed files with 459 additions and 399 deletions
@ -0,0 +1,49 @@ |
|||
using System.Text.RegularExpressions; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.BlobStoring.Aliyun |
|||
{ |
|||
public class AliyunBlobNamingNormalizer : IBlobNamingNormalizer, ITransientDependency |
|||
{ |
|||
public virtual string NormalizeBlobName(string blobName) |
|||
{ |
|||
return blobName; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 阿里云BucketName命名规范
|
|||
/// https://help.aliyun.com/document_detail/31885.html?spm=a2c4g.11186623.6.583.56081c62w6meOR
|
|||
/// </summary>
|
|||
/// <param name="blobName"></param>
|
|||
/// <returns></returns>
|
|||
public virtual string NormalizeContainerName(string containerName) |
|||
{ |
|||
// 小写字母、数字和短划线(-)
|
|||
containerName = containerName.ToLower(); |
|||
containerName = Regex.Replace(containerName, "[^a-z0-9-]", string.Empty); |
|||
|
|||
// 不能以短划线(-)开头
|
|||
containerName = Regex.Replace(containerName, "^-", string.Empty); |
|||
// 不能以短划线(-)结尾
|
|||
containerName = Regex.Replace(containerName, "-$", string.Empty); |
|||
|
|||
// 长度必须在3-63之间
|
|||
if (containerName.Length < 3) |
|||
{ |
|||
var length = containerName.Length; |
|||
for (var i = 0; i < 3 - length; i++) |
|||
{ |
|||
containerName += "0"; |
|||
} |
|||
} |
|||
|
|||
if (containerName.Length > 63) |
|||
{ |
|||
containerName = containerName.Substring(0, 63); |
|||
} |
|||
|
|||
return containerName; |
|||
} |
|||
} |
|||
} |
|||
@ -1,6 +1,7 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"TextTemplate:ExceptionHandlingTemplates.SendEmail": "Apply the exception message sending template", |
|||
"SendEmailTitle": "Application exception push", |
|||
"SendEmailHeader": "Application exception" |
|||
} |
|||
|
|||
@ -1,6 +1,7 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"TextTemplate:ExceptionHandlingTemplates.SendEmail": "应用异常邮件发送模板", |
|||
"SendEmailTitle": "应用程序异常推送", |
|||
"SendEmailHeader": "应用程序异常" |
|||
} |
|||
|
|||
@ -1,8 +1,16 @@ |
|||
namespace LINGYUN.Abp.SettingManagement |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.SettingManagement; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.SettingManagement |
|||
{ |
|||
public class UpdateSettingDto |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(SettingConsts), nameof(SettingConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
|
|||
[DynamicStringLength(typeof(SettingConsts), nameof(SettingConsts.MaxValueLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
|
|||
@ -1,17 +1,18 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.TenantManagement; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.TenantManagement |
|||
{ |
|||
public class TenantConnectionStringCreateOrUpdateDto |
|||
{ |
|||
[Required] |
|||
[StringLength(TenantConnectionStringConsts.MaxNameLength)] |
|||
[DynamicStringLength(typeof(TenantConnectionStringConsts), nameof(TenantConnectionStringConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(TenantConnectionStringConsts.MaxValueLength)] |
|||
[DynamicStringLength(typeof(TenantConnectionStringConsts), nameof(TenantConnectionStringConsts.MaxValueLength))] |
|||
public string Value { get; set; } |
|||
} |
|||
} |
|||
|
|||
@ -1,13 +1,15 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.Abp.TenantManagement; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.TenantManagement |
|||
{ |
|||
public abstract class TenantCreateOrUpdateDtoBase : ExtensibleObject |
|||
{ |
|||
[Required] |
|||
[StringLength(TenantConsts.MaxNameLength)] |
|||
[DynamicStringLength(typeof(TenantConsts), nameof(TenantConsts.MaxNameLength))] |
|||
|
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -1,115 +0,0 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Clients; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Settings; |
|||
using Volo.Abp.Timing; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Platform.AspNetCore.Mvc.ApplicationConfigurations |
|||
{ |
|||
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] |
|||
[ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationAppService))] |
|||
public class ApplicationConfigurationAppService : AbpApplicationConfigurationAppService |
|||
{ |
|||
private readonly IPermissionGrantRepository _permissionGrantRepository; |
|||
private readonly IPermissionDefinitionManager _permissionDefinitionManager; |
|||
|
|||
private ICurrentClient _currentClient; |
|||
|
|||
protected ICurrentClient CurrentClient => LazyGetRequiredService(ref _currentClient); |
|||
|
|||
public ApplicationConfigurationAppService( |
|||
IOptions<AbpLocalizationOptions> localizationOptions, |
|||
IOptions<AbpMultiTenancyOptions> multiTenancyOptions, |
|||
IServiceProvider serviceProvider, |
|||
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider, |
|||
IAuthorizationService authorizationService, |
|||
ICurrentUser currentUser, |
|||
ISettingProvider settingProvider, |
|||
ISettingDefinitionManager settingDefinitionManager, |
|||
IFeatureDefinitionManager featureDefinitionManager, |
|||
ILanguageProvider languageProvider, |
|||
ITimezoneProvider timezoneProvider, |
|||
IOptions<AbpClockOptions> abpClockOptions, |
|||
ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService, |
|||
IPermissionGrantRepository permissionGrantRepository, |
|||
IPermissionDefinitionManager permissionDefinitionManager) |
|||
: base( |
|||
localizationOptions, |
|||
multiTenancyOptions, |
|||
serviceProvider, |
|||
abpAuthorizationPolicyProvider, |
|||
authorizationService, |
|||
currentUser, |
|||
settingProvider, |
|||
settingDefinitionManager, |
|||
featureDefinitionManager, |
|||
languageProvider, |
|||
timezoneProvider, |
|||
abpClockOptions, |
|||
cachedObjectExtensionsDtoService) |
|||
{ |
|||
_permissionGrantRepository = permissionGrantRepository; |
|||
_permissionDefinitionManager = permissionDefinitionManager; |
|||
|
|||
} |
|||
protected override async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync() |
|||
{ |
|||
var authConfig = new ApplicationAuthConfigurationDto(); |
|||
|
|||
var permissions = _permissionDefinitionManager.GetPermissions(); |
|||
|
|||
IEnumerable<PermissionGrant> grantPermissions = new List<PermissionGrant>(); |
|||
|
|||
// TODO: 重写为每次调用接口都在数据库统一查询权限
|
|||
// 待框架改进权限Provider机制后再移除
|
|||
|
|||
// 如果用户已登录,获取用户和角色权限
|
|||
if (CurrentUser.IsAuthenticated) |
|||
{ |
|||
var userPermissions = await _permissionGrantRepository.GetListAsync(UserPermissionValueProvider.ProviderName, |
|||
CurrentUser.GetId().ToString()); |
|||
grantPermissions = grantPermissions.Union(userPermissions); |
|||
foreach(var userRole in CurrentUser.Roles) |
|||
{ |
|||
var rolePermissions = await _permissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, |
|||
userRole); |
|||
grantPermissions = grantPermissions.Union(rolePermissions); |
|||
} |
|||
} |
|||
|
|||
// 如果客户端已验证,获取客户端权限
|
|||
if(CurrentClient.IsAuthenticated) |
|||
{ |
|||
var clientPermissions = await _permissionGrantRepository.GetListAsync(ClientPermissionValueProvider.ProviderName, |
|||
CurrentClient.Id); |
|||
grantPermissions = grantPermissions.Union(clientPermissions); |
|||
} |
|||
|
|||
foreach(var permission in permissions) |
|||
{ |
|||
authConfig.Policies[permission.Name] = true; |
|||
if(grantPermissions.Any(p => p.Name.Equals(permission.Name))) |
|||
{ |
|||
authConfig.GrantedPolicies[permission.Name] = true; |
|||
} |
|||
} |
|||
|
|||
return authConfig; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue