mirror of https://github.com/abpframework/abp.git
51 changed files with 317 additions and 242 deletions
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public interface IUserRoleFinder |
|||
{ |
|||
Task<string[]> GetRolesAsync(Guid userId); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class UserRoleFinder : IUserRoleFinder, ITransientDependency |
|||
{ |
|||
private readonly IIdentityUserRepository _identityUserRepository; |
|||
|
|||
public UserRoleFinder(IIdentityUserRepository identityUserRepository) |
|||
{ |
|||
_identityUserRepository = identityUserRepository; |
|||
} |
|||
|
|||
public async Task<string[]> GetRolesAsync(Guid userId) |
|||
{ |
|||
return (await _identityUserRepository.GetRoleNamesAsync(userId)).ToArray(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[Dependency(TryRegister = true)] |
|||
public class HttpClientUserRoleFinder : IUserRoleFinder, ITransientDependency |
|||
{ |
|||
private readonly IIdentityUserAppService _userAppService; |
|||
|
|||
public HttpClientUserRoleFinder(IIdentityUserAppService userAppService) |
|||
{ |
|||
_userAppService = userAppService; |
|||
} |
|||
|
|||
public async Task<string[]> GetRolesAsync(Guid userId) |
|||
{ |
|||
var output = await _userAppService.GetRolesAsync(userId); |
|||
return output.Items.Select(r => r.Name).ToArray(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,51 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement; |
|||
|
|||
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 virtual 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 virtual 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(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.PermissionManagement.Domain.Identity</AssemblyName> |
|||
<PackageId>Volo.Abp.PermissionManagement.Domain.Identity</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Identity.Domain.Shared\Volo.Abp.Identity.Domain.Shared.csproj" /> |
|||
<ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Domain\Volo.Abp.PermissionManagement.Domain.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,16 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.PermissionManagement.Identity |
|||
{ |
|||
public class AbpPermissionManagementDomainIdentityModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<PermissionManagementOptions>(options => |
|||
{ |
|||
options.ManagementProviders.Add<UserPermissionManagementProvider>(); |
|||
options.ManagementProviders.Add<RolePermissionManagementProvider>(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,8 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
namespace Volo.Abp.PermissionManagement.Identity |
|||
{ |
|||
public class UserPermissionManagementProvider : PermissionManagementProvider |
|||
{ |
|||
@ -1,12 +1,13 @@ |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.Abp.PermissionManagement |
|||
{ |
|||
public interface IPermissionAppServiceHelper |
|||
public interface IPermissionAppService : IApplicationService |
|||
{ |
|||
Task<GetPermissionListResultDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey); |
|||
|
|||
Task UpdateAsync([NotNull] string providerName, [NotNull] string providerKey, UpdatePermissionsDto input); |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +1,20 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.PermissionManagement |
|||
{ |
|||
public class PermissionAppServiceHelper : IPermissionAppServiceHelper, ITransientDependency |
|||
//[Authorize]
|
|||
public class PermissionAppService : ApplicationService, IPermissionAppService |
|||
{ |
|||
private readonly IPermissionManager _permissionManager; |
|||
private readonly IPermissionDefinitionManager _permissionDefinitionManager; |
|||
private readonly IStringLocalizerFactory _stringLocalizerFactory; |
|||
|
|||
public PermissionAppServiceHelper( |
|||
public PermissionAppService( |
|||
IPermissionManager permissionManager, |
|||
IPermissionDefinitionManager permissionDefinitionManager, |
|||
IStringLocalizerFactory stringLocalizerFactory) |
|||
@ -0,0 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.PermissionManagement.HttpApi.Client</AssemblyName> |
|||
<PackageId>Volo.Abp.PermissionManagement.HttpApi.Client</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.PermissionManagement.Application.Contracts\Volo.Abp.PermissionManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Http.Client\Volo.Abp.Http.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,22 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.PermissionManagement |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpPermissionManagementApplicationContractsModule), |
|||
typeof(AbpHttpClientModule))] |
|||
public class AbpPermissionManagementHttpApiClientModule : AbpModule |
|||
{ |
|||
public const string RemoteServiceName = "AbpPermissionManagement"; |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddHttpClientProxies( |
|||
typeof(AbpPermissionManagementApplicationContractsModule).Assembly, |
|||
RemoteServiceName |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.PermissionManagement.HttpApi</AssemblyName> |
|||
<PackageId>Volo.Abp.PermissionManagement.HttpApi</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.PermissionManagement.Application.Contracts\Volo.Abp.PermissionManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,14 @@ |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.PermissionManagement.HttpApi |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpPermissionManagementApplicationContractsModule), |
|||
typeof(AbpAspNetCoreMvcModule) |
|||
)] |
|||
public class AbpPermissionManagementHttpApiModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace Volo.Abp.PermissionManagement |
|||
{ |
|||
[RemoteService] |
|||
[Area("abp")] |
|||
public class PermissionsController : AbpController, IPermissionAppService |
|||
{ |
|||
private readonly IPermissionAppService _permissionAppService; |
|||
|
|||
public PermissionsController(IPermissionAppService permissionAppService) |
|||
{ |
|||
_permissionAppService = permissionAppService; |
|||
} |
|||
|
|||
public Task<GetPermissionListResultDto> GetAsync(string providerName, string providerKey) |
|||
{ |
|||
return _permissionAppService.GetAsync(providerName, providerKey); |
|||
} |
|||
|
|||
public Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input) |
|||
{ |
|||
return _permissionAppService.UpdateAsync(providerName, providerKey, input); |
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement |
|||
{ |
|||
public interface IPermissionAppServiceGateway |
|||
{ |
|||
Task<GetPermissionListResultDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey); |
|||
|
|||
Task UpdateAsync([NotNull] string providerName, [NotNull] string providerKey, UpdatePermissionsDto input); |
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.PermissionManagement.Web.Pages.AbpPermissionManagement |
|||
{ |
|||
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