-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17337 from abpframework/PermissionIntegrationService
Add `PermissionIntegrationService` to permission-management module.
- Loading branch information
Showing
10 changed files
with
274 additions
and
5 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...tion.Contracts/Volo/Abp/PermissionManagement/Integration/IPermissionIntegrationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Application.Services; | ||
|
||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
[IntegrationService] | ||
public interface IPermissionIntegrationService : IApplicationService | ||
{ | ||
Task<ListResultDto<PermissionGrantOutput>> IsGrantedAsync(List<PermissionGrantInput> input); | ||
} |
10 changes: 10 additions & 0 deletions
10
...t.Application.Contracts/Volo/Abp/PermissionManagement/Integration/PermissionGrantInput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
public class PermissionGrantInput | ||
{ | ||
public Guid UserId { get; set; } | ||
|
||
public string[] PermissionNames { get; set; } | ||
} |
11 changes: 11 additions & 0 deletions
11
....Application.Contracts/Volo/Abp/PermissionManagement/Integration/PermissionGrantOutput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
public class PermissionGrantOutput | ||
{ | ||
public Guid UserId { get; set; } | ||
|
||
public Dictionary<string, bool> Permissions { get; set; } | ||
} |
35 changes: 35 additions & 0 deletions
35
...ent.Application/Volo/Abp/PermissionManagement/Integration/PermissionIntegrationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Application.Services; | ||
using Volo.Abp.Authorization.Permissions; | ||
|
||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
[IntegrationService] | ||
public class PermissionIntegrationService : ApplicationService, IPermissionIntegrationService | ||
{ | ||
protected IPermissionManager PermissionManager { get; } | ||
|
||
public PermissionIntegrationService(IPermissionManager permissionManager) | ||
{ | ||
PermissionManager = permissionManager; | ||
} | ||
|
||
public virtual async Task<ListResultDto<PermissionGrantOutput>> IsGrantedAsync(List<PermissionGrantInput> input) | ||
{ | ||
var result = new List<PermissionGrantOutput>(); | ||
foreach (var item in input) | ||
{ | ||
result.Add(new PermissionGrantOutput | ||
{ | ||
UserId = item.UserId, | ||
Permissions = (await PermissionManager.GetAsync(item.PermissionNames, UserPermissionValueProvider.ProviderName, item.UserId.ToString())).Result | ||
.ToDictionary(x => x.Name, x => x.IsGranted) | ||
}); | ||
} | ||
|
||
return new ListResultDto<PermissionGrantOutput>(result); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...s/Volo/Abp/PermissionManagement/Integration/PermissionIntegrationClientProxy.Generated.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Volo.Abp; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.Http.Client; | ||
using Volo.Abp.Http.Client.ClientProxying; | ||
using Volo.Abp.Http.Modeling; | ||
using Volo.Abp.PermissionManagement.Integration; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
[Dependency(ReplaceServices = true)] | ||
[ExposeServices(typeof(IPermissionIntegrationService), typeof(PermissionIntegrationClientProxy))] | ||
[IntegrationService] | ||
public partial class PermissionIntegrationClientProxy : ClientProxyBase<IPermissionIntegrationService>, IPermissionIntegrationService | ||
{ | ||
public virtual async Task<ListResultDto<PermissionGrantOutput>> IsGrantedAsync(List<PermissionGrantInput> input) | ||
{ | ||
return await RequestAsync<ListResultDto<PermissionGrantOutput>>(nameof(IsGrantedAsync), new ClientProxyRequestTypeValue | ||
{ | ||
{ typeof(List<PermissionGrantInput>), input } | ||
}); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ientProxies/Volo/Abp/PermissionManagement/Integration/PermissionIntegrationClientProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This file is part of PermissionIntegrationClientProxy, you can customize it here | ||
// ReSharper disable once CheckNamespace | ||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
public partial class PermissionIntegrationClientProxy | ||
{ | ||
} |
8 changes: 5 additions & 3 deletions
8
...oxies/PermissionsClientProxy.Generated.cs → ...ement/PermissionsClientProxy.Generated.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...t/ClientProxies/PermissionsClientProxy.cs → ...ssionManagement/PermissionsClientProxy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ment.HttpApi/Volo/Abp/PermissionManagement/Integration/PermissionIntegrationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.AspNetCore.Mvc; | ||
|
||
namespace Volo.Abp.PermissionManagement.Integration; | ||
|
||
[RemoteService(Name = PermissionManagementRemoteServiceConsts.RemoteServiceName)] | ||
[Area(PermissionManagementRemoteServiceConsts.ModuleName)] | ||
[ControllerName("PermissionIntegration")] | ||
[Route("integration-api/permission-management/permissions")] | ||
public class PermissionIntegrationController: AbpControllerBase, IPermissionIntegrationService | ||
{ | ||
protected IPermissionIntegrationService PermissionIntegrationService { get; } | ||
|
||
public PermissionIntegrationController(IPermissionIntegrationService permissionIntegrationService) | ||
{ | ||
PermissionIntegrationService = permissionIntegrationService; | ||
} | ||
|
||
[HttpGet] | ||
[Route("is-granted")] | ||
public virtual Task<ListResultDto<PermissionGrantOutput>> IsGrantedAsync(List<PermissionGrantInput> input) | ||
{ | ||
return PermissionIntegrationService.IsGrantedAsync(input); | ||
} | ||
} |