Remove tenant permission provider

pull/848/head
Halil ibrahim Kalkan 6 years ago
parent fcaa705841
commit 2b403ada8b

@ -24,11 +24,6 @@ namespace Volo.Abp.Authorization.Permissions
/// </summary>
public List<string> Providers { get; } //TODO: Rename to AllowedProviders?
/// <summary>
/// Used to mark this permission as also a feature of the application.
/// </summary>
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<string, object>();
Providers = new List<string>();
@ -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
};

@ -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);

@ -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<PermissionOptions>(options =>
{
options.ValueProviders.Add<TenantPermissionValueProvider>();
});
}
}
}

@ -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<PermissionGrantResult> 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;
}
}
}
}
Loading…
Cancel
Save