From 2b403ada8ba88c03da15d27f80cb57f97d800cc7 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 27 Feb 2019 11:49:36 +0300 Subject: [PATCH] Remove tenant permission provider --- .../Permissions/PermissionDefinition.cs | 14 ++---- .../Permissions/PermissionGroupDefinition.cs | 5 +-- .../AbpMultiTenancyAbstractionsModule.cs | 9 +--- .../TenantPermissionValueProvider.cs | 45 ------------------- 4 files changed, 6 insertions(+), 67 deletions(-) delete mode 100644 framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/TenantPermissionValueProvider.cs diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs index ce81f4e00d..de4ca1221f 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs @@ -24,11 +24,6 @@ namespace Volo.Abp.Authorization.Permissions /// public List Providers { get; } //TODO: Rename to AllowedProviders? - /// - /// Used to mark this permission as also a feature of the application. - /// - public bool IsFeature { get; set; } - public ILocalizableString DisplayName { get => _displayName; @@ -60,12 +55,10 @@ namespace Volo.Abp.Authorization.Permissions protected internal PermissionDefinition( [NotNull] string name, - ILocalizableString displayName = null, - bool isFeature = false) + ILocalizableString displayName = null) { Name = Check.NotNull(name, nameof(name)); DisplayName = displayName ?? new FixedLocalizableString(name); - IsFeature = isFeature; Properties = new Dictionary(); Providers = new List(); @@ -74,10 +67,9 @@ namespace Volo.Abp.Authorization.Permissions public virtual PermissionDefinition AddChild( [NotNull] string name, - ILocalizableString displayName = null, - bool isFeature = false) + ILocalizableString displayName = null) { - var child = new PermissionDefinition(name, displayName, isFeature) + var child = new PermissionDefinition(name, displayName) { Parent = this }; diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs index c4fe93e739..623db24c8a 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs @@ -50,10 +50,9 @@ namespace Volo.Abp.Authorization.Permissions public virtual PermissionDefinition AddPermission( string name, - ILocalizableString displayName = null, - bool isFeature = false) + ILocalizableString displayName = null) { - var permission = new PermissionDefinition(name, displayName, isFeature); + var permission = new PermissionDefinition(name, displayName); _permissions.Add(permission); diff --git a/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs b/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs index 1b72b7d292..6b21f53443 100644 --- a/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs +++ b/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs @@ -1,5 +1,4 @@ using Volo.Abp.Authorization; -using Volo.Abp.Authorization.Permissions; using Volo.Abp.Data; using Volo.Abp.Modularity; @@ -11,12 +10,6 @@ namespace Volo.Abp.MultiTenancy )] public class AbpMultiTenancyAbstractionsModule : AbpModule //TODO: Rename to AbpMultiTenancyModule? { - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.ValueProviders.Add(); - }); - } + } } diff --git a/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/TenantPermissionValueProvider.cs b/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/TenantPermissionValueProvider.cs deleted file mode 100644 index 94bd018823..0000000000 --- a/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/TenantPermissionValueProvider.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Authorization.Permissions; -using Volo.Abp.Security.Claims; - -namespace Volo.Abp.MultiTenancy -{ - public class TenantPermissionValueProvider : PermissionValueProvider - { - public const string ProviderName = "Tenant"; - - public override string Name => ProviderName; - - protected ICurrentTenant CurrentTenant { get; } - - public TenantPermissionValueProvider( - IPermissionStore permissionStore, - ICurrentTenant currentTenant) - : base(permissionStore) - { - CurrentTenant = currentTenant; - } - - public override async Task CheckAsync(PermissionValueCheckContext context) - { - if (!context.Permission.IsFeature) - { - return PermissionGrantResult.Undefined; - } - - var tenantId = context.Principal?.FindFirst(AbpClaimTypes.TenantId)?.Value; - - if (tenantId == null) - { - return PermissionGrantResult.Undefined; - } - - using (CurrentTenant.Change(null)) - { - return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, tenantId) - ? PermissionGrantResult.Granted - : PermissionGrantResult.Undefined; - } - } - } -}