DynamicAuthorization.Mvc.Core by Mohsen Esmailpour

<PackageReference Include="DynamicAuthorization.Mvc.Core" Version="1.0.3" />

 SecureContentTagHelper<TDbContext, TUser, TRole, TKey>

public abstract class SecureContentTagHelper<TDbContext, TUser, TRole, TKey> : TagHelper where TDbContext : IdentityDbContext<TUser, TRole, TKey> where TUser : IdentityUser<TKey> where TRole : IdentityRole<TKey> where TKey : IEquatable<TKey>
using DynamicAuthorization.Mvc.Core.Models; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace DynamicAuthorization.Mvc.Core { public abstract class SecureContentTagHelper<TDbContext, TUser, TRole, TKey> : TagHelper where TDbContext : IdentityDbContext<TUser, TRole, TKey> where TUser : IdentityUser<TKey> where TRole : IdentityRole<TKey> where TKey : IEquatable<TKey> { private readonly TDbContext _dbContext; private readonly DynamicAuthorizationOptions _authorizationOptions; private readonly IRoleAccessStore _roleAccessStore; [HtmlAttributeName("asp-area")] public string Area { get; set; } [HtmlAttributeName("asp-controller")] public string Controller { get; set; } [HtmlAttributeName("asp-action")] public string Action { get; set; } [ViewContext] [HtmlAttributeNotBound] public ViewContext ViewContext { get; set; } public SecureContentTagHelper(TDbContext dbContext, DynamicAuthorizationOptions authorizationOptions, IRoleAccessStore roleAccessStore) { _dbContext = dbContext; _authorizationOptions = authorizationOptions; _roleAccessStore = roleAccessStore; } [AsyncStateMachine(typeof(SecureContentTagHelper<, , , >.<ProcessAsync>d__20))] public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { <ProcessAsync>d__20 stateMachine = default(<ProcessAsync>d__20); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.output = output; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start<<ProcessAsync>d__20>(ref stateMachine); return stateMachine.<>t__builder.Task; } } }