mirror of https://github.com/abpframework/abp.git
19 changed files with 143 additions and 54 deletions
@ -0,0 +1,51 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Permissions; |
|||
using Volo.Abp.Permissions.Web.Pages.AbpPermissions; |
|||
|
|||
namespace Volo.Abp.Identity.Web.Permissions |
|||
{ |
|||
//TODO: Instead of creating such a gateway/adapter, we can implement a common interface for app services, like IHasPermissionManagementApi and manage it dynamically!
|
|||
|
|||
public class IdentityPermissionAppServiceGateway : IPermissionAppServiceGateway, ITransientDependency |
|||
{ |
|||
private readonly IIdentityUserAppService _userAppService; |
|||
private readonly IIdentityRoleAppService _roleAppService; |
|||
|
|||
public IdentityPermissionAppServiceGateway(IIdentityUserAppService userAppService, IIdentityRoleAppService roleAppService) |
|||
{ |
|||
_userAppService = userAppService; |
|||
_roleAppService = roleAppService; |
|||
} |
|||
|
|||
public async Task<GetPermissionListResultDto> GetAsync(string providerName, string providerKey) |
|||
{ |
|||
switch (providerName) |
|||
{ |
|||
case UserPermissionValueProvider.ProviderName: |
|||
return await _userAppService.GetPermissionsAsync(Guid.Parse(providerKey)); |
|||
case RolePermissionValueProvider.ProviderName: |
|||
return await _roleAppService.GetPermissionsAsync(Guid.Parse(providerKey)); |
|||
default: |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
|
|||
public async Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input) |
|||
{ |
|||
switch (providerName) |
|||
{ |
|||
case UserPermissionValueProvider.ProviderName: |
|||
await _userAppService.UpdatePermissionsAsync(Guid.Parse(providerKey), input); |
|||
break; |
|||
case RolePermissionValueProvider.ProviderName: |
|||
await _roleAppService.UpdatePermissionsAsync(Guid.Parse(providerKey), input); |
|||
break; |
|||
default: |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,13 +0,0 @@ |
|||
namespace Volo.Abp.Permissions |
|||
{ |
|||
public static class PermissionPermissions |
|||
{ |
|||
public const string GroupName = "AbpPermissions"; |
|||
|
|||
public static class Permissions |
|||
{ |
|||
public const string Default = GroupName + ".Permissions"; |
|||
public const string Update = Default + ".Update"; |
|||
} |
|||
} |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
|
|||
namespace Volo.Abp.Permissions |
|||
{ |
|||
public class PermissionsPermissionDefinitionProvider : PermissionDefinitionProvider |
|||
{ |
|||
public override void Define(IPermissionDefinitionContext context) |
|||
{ |
|||
var group = context.AddGroup(PermissionPermissions.GroupName); |
|||
|
|||
var permissions = group.AddPermission(PermissionPermissions.Permissions.Default); |
|||
permissions.AddChild(PermissionPermissions.Permissions.Update); |
|||
} |
|||
} |
|||
} |
|||
@ -1,10 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.Abp.Permissions |
|||
{ |
|||
public interface IPermissionAppService : IApplicationService |
|||
public interface IPermissionAppServiceHelper |
|||
{ |
|||
Task<GetPermissionListResultDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey); |
|||
|
|||
@ -0,0 +1,12 @@ |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.Permissions.Web.Pages.AbpPermissions |
|||
{ |
|||
public interface IPermissionAppServiceGateway |
|||
{ |
|||
Task<GetPermissionListResultDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey); |
|||
|
|||
Task UpdateAsync([NotNull] string providerName, [NotNull] string providerKey, UpdatePermissionsDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Permissions.Web.Pages.AbpPermissions |
|||
{ |
|||
public class NotImplementedPermissionAppServiceGateway : IPermissionAppServiceGateway, ISingletonDependency |
|||
{ |
|||
public Task<GetPermissionListResultDto> GetAsync(string providerName, string providerKey) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
|
|||
public Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue