mirror of https://github.com/abpframework/abp.git
Browse Source
Introduces `IsAvailableAsync()` to `IResourcePermissionManagementProvider` and `IResourcePermissionProviderKeyLookupService`, allowing providers to opt out in certain contexts. `ResourcePermissionManager` respects this flag in permission checks, writes, and UI lookup service listing. OpenIddict and IdentityServer client providers override `IsAvailableAsync()` to return `false` when the current context is a tenant (host-only concept).pull/24951/head
15 changed files with 187 additions and 4 deletions
@ -0,0 +1,26 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.PermissionManagement; |
|||
|
|||
public class TestUnavailableResourcePermissionManagementProvider : ResourcePermissionManagementProvider |
|||
{ |
|||
public override string Name => "TestUnavailable"; |
|||
|
|||
public TestUnavailableResourcePermissionManagementProvider( |
|||
IResourcePermissionGrantRepository resourcePermissionGrantRepository, |
|||
IGuidGenerator guidGenerator, |
|||
ICurrentTenant currentTenant) |
|||
: base( |
|||
resourcePermissionGrantRepository, |
|||
guidGenerator, |
|||
currentTenant) |
|||
{ |
|||
} |
|||
|
|||
public override Task<bool> IsAvailableAsync() |
|||
{ |
|||
return Task.FromResult(false); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace Volo.Abp.PermissionManagement; |
|||
|
|||
public class TestUnavailableResourcePermissionProviderKeyLookupService : IResourcePermissionProviderKeyLookupService, ITransientDependency |
|||
{ |
|||
public string Name => "TestUnavailable"; |
|||
|
|||
public ILocalizableString DisplayName => new LocalizableString("TestUnavailable", "TestResource"); |
|||
|
|||
public Task<bool> IsAvailableAsync() |
|||
{ |
|||
return Task.FromResult(false); |
|||
} |
|||
|
|||
public Task<List<ResourcePermissionProviderKeyInfo>> SearchAsync(string filter = null, int page = 1, CancellationToken cancellationToken = default) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
|
|||
public Task<List<ResourcePermissionProviderKeyInfo>> SearchAsync(string[] keys, CancellationToken cancellationToken = default) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue