diff --git a/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs b/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs index a4cbb27da5..9d16a6a55c 100644 --- a/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs +++ b/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs @@ -1,25 +1,12 @@ using System.Collections.Generic; -using System.Security.Claims; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Authorization; -using Volo.Abp.Threading; namespace Microsoft.AspNetCore.Authorization { - // TODO: Complete all Sync extension methods! public static class AbpAuthorizationServiceExtensions { - public static AuthorizationResult Authorize(this IAuthorizationService authorizationService, ClaimsPrincipal user, object resource, string policyName) - { - return AsyncHelper.RunSync(() => authorizationService.AuthorizeAsync(user, resource, policyName)); - } - - public static AuthorizationResult Authorize(this IAuthorizationService authorizationService, ClaimsPrincipal user, object resource, IEnumerable requirements) - { - return AsyncHelper.RunSync(() => authorizationService.AuthorizeAsync(user, resource, requirements)); - } - public static Task AuthorizeAsync(this IAuthorizationService authorizationService, string policyName) { return AuthorizeAsync( @@ -29,15 +16,6 @@ namespace Microsoft.AspNetCore.Authorization ); } - public static AuthorizationResult Authorize(this IAuthorizationService authorizationService, string policyName) - { - return Authorize( - authorizationService, - authorizationService.AsAbpAuthorizationService().CurrentPrincipal, - policyName - ); - } - public static Task AuthorizeAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement) { return authorizationService.AuthorizeAsync( @@ -81,25 +59,11 @@ namespace Microsoft.AspNetCore.Authorization ); } - public static AuthorizationResult Authorize(this IAuthorizationService authorizationService, object resource, string policyName) - { - return authorizationService.Authorize( - authorizationService.AsAbpAuthorizationService().CurrentPrincipal, - resource, - policyName - ); - } - public static async Task IsGrantedAsync(this IAuthorizationService authorizationService, string policyName) { return (await authorizationService.AuthorizeAsync(policyName)).Succeeded; } - public static bool IsGranted(this IAuthorizationService authorizationService, string policyName) - { - return authorizationService.Authorize(policyName).Succeeded; - } - public static async Task IsGrantedAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement) { return (await authorizationService.AuthorizeAsync(resource, requirement)).Succeeded; @@ -133,11 +97,6 @@ namespace Microsoft.AspNetCore.Authorization } } - public static void Check(this IAuthorizationService authorizationService, string policyName) - { - AsyncHelper.RunSync(() => authorizationService.CheckAsync(policyName)); - } - public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement) { if (!await authorizationService.IsGrantedAsync(resource, requirement)) diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs index 909ad40940..698f2c0ea3 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs @@ -124,20 +124,5 @@ namespace Volo.Abp.Application.Services await AuthorizationService.CheckAsync(policyName); } - - /// - /// Checks for given . - /// Throws if given policy has not been granted. - /// - /// The policy name. This method does nothing if given is null or empty. - protected virtual void CheckPolicy([CanBeNull] string policyName) - { - if (string.IsNullOrEmpty(policyName)) - { - return; - } - - AuthorizationService.Check(policyName); - } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs index d3ed32be85..d4960c883e 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using JetBrains.Annotations; -using Volo.Abp.UI.Navigation; namespace Volo.Abp.UI.Navigation {