mirror of https://github.com/abpframework/abp.git
10 changed files with 173 additions and 41 deletions
@ -1,10 +1,11 @@ |
|||||
using System.Threading.Tasks; |
using System.Security.Claims; |
||||
using Microsoft.AspNetCore.Authorization; |
using Microsoft.AspNetCore.Authorization; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
namespace Volo.Abp.Authorization |
namespace Volo.Abp.Authorization |
||||
{ |
{ |
||||
public interface IAbpAuthorizationService : IAuthorizationService |
public interface IAbpAuthorizationService : IAuthorizationService, IServiceProviderAccessor |
||||
{ |
{ |
||||
Task CheckAsync(string policyName); |
ClaimsPrincipal CurrentPrincipal { get; } |
||||
} |
} |
||||
} |
} |
||||
@ -1,26 +1,34 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
using Volo.Abp.Ui.Navigation; |
using Volo.Abp.Ui.Navigation; |
||||
|
|
||||
namespace Volo.Abp.Identity.Web.Navigation |
namespace Volo.Abp.Identity.Web.Navigation |
||||
{ |
{ |
||||
public class AbpIdentityWebMainMenuContributor : IMenuContributor |
public class AbpIdentityWebMainMenuContributor : IMenuContributor |
||||
{ |
{ |
||||
public Task ConfigureMenuAsync(MenuConfigurationContext context) |
public async Task ConfigureMenuAsync(MenuConfigurationContext context) |
||||
{ |
{ |
||||
if (context.Menu.Name != StandardMenus.Main) |
if (context.Menu.Name != StandardMenus.Main) |
||||
{ |
{ |
||||
return Task.CompletedTask; |
return; |
||||
} |
} |
||||
|
|
||||
context.Menu |
var permissionChecker = context.ServiceProvider.GetRequiredService<IPermissionChecker>(); |
||||
.AddItem( |
|
||||
new ApplicationMenuItem("Identity", "Identity") |
|
||||
.AddItem(new ApplicationMenuItem("Users", "Users", url: "/Identity/Users")) |
|
||||
.AddItem(new ApplicationMenuItem("Roles", "Roles", url: "/Identity/Roles")) |
|
||||
|
|
||||
); |
var identityMenuItem = new ApplicationMenuItem("Identity", "Identity"); |
||||
|
|
||||
return Task.CompletedTask; |
context.Menu.AddItem(identityMenuItem); |
||||
|
|
||||
|
if (await permissionChecker.IsGrantedAsync(IdentityPermissions.Roles.Default)) |
||||
|
{ |
||||
|
identityMenuItem.AddItem(new ApplicationMenuItem("Roles", "Roles", url: "/Identity/Roles")); |
||||
|
} |
||||
|
|
||||
|
if (await permissionChecker.IsGrantedAsync(IdentityPermissions.Users.Default)) |
||||
|
{ |
||||
|
identityMenuItem.AddItem(new ApplicationMenuItem("Users", "Users", url: "/Identity/Users")); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue