verify-permission

The verify-permission tag helper display its content if all permissions listed in its required-permissions attribute, are granted for the current user according to the Func<IPrincipal, Functionalities> passed in its permissions attribute.

required-permissions: Functionalities
All permission needed to show the tag helper content
permissions: Func<IPrincipal, Functionalities>
A function that computes the current user permissions. If the verify-permission tag helper is placed in a toolbar this function is inherited from the ancestor tag helper.
client-permissions: string
It make sense just for client providers. The name of a method of the client side ViewModel that computes the current user permissions.If the verify-permission tag helper is placed in a toolbar this function is inherited from the ancestor tag helper.
query-for: ModelExpression
A property containing a QueryDescription object. If provided tag helper content is shown only if the query contained the QueryDescription object is not in grouping mode. If the verify-permission tag helper is placed in a toolbar this function is inherited from the ancestor tag helper. Useful to hide add buttons when a control, like a grid, is in grouping mode.
A grid that uses the required-permissions tag helper to hide its add buttons when appropriate (see it live here):

@model LiveExamples.Viemodels.SimpleProductlistViewModel
@{
    ViewData["Title"] = "Edit-in line server grid with query";
    if (Model.Query.AttachedTo == null)
    {
        Model.Query.AttachEndpoint(Url.Action("AjaxServerQuery""Grids"));
    }
}
...
...
...
@*antiforgery is compulsory *@
<form asp-antiforgery="true">
    <div asp-validation-summary="All" class="text-danger"></div>
    <grid asp-for="Products.Data"
          type="Immediate"
          all-properties="true"
          mvc-controller="typeof(LiveExamples.Controllers.GridsController)"
          row-id="immediate-edit-inline-query"
          operations="user => Functionalities.FullInLine"
          query-for="Query"
          sorting-clauses="2"
          enable-query="true"
          query-grouping-type="typeof(SimpleProductViewModel)"
          class="table table-condensed table-bordered">
        <toolbar zone-name="@LayoutStandardPlaces.Header">
            <pager class="pagination pagination-sm"
                   max-pages="4"
                   page-size-default="5"
                   total-pages="Products.TotalPages" />
            &nbsp;
            <query type="Filtering" />
            <query type="Sorting" />
            <query type="Grouping" />
            <verify-permission required-permissions="@(Functionalities.Append)">
                <button type="button" data-operation="add append 0"
                        class="btn btn-sm btn-primary">
                    new product
                </button>
            </verify-permission>
        </toolbar>
    </grid>
</form>


Fork me on GitHub