# Security Trimming

The Telerik UI Menu has a built-in security trimming functionality which is enabled by default.

If the URL to which the Menu item points is not authorized, the item is hidden.

Security trimming depends on the [ASP.NET Core Authorization](https://docs.microsoft.com/en-us/aspnet/core/security/authorization/introduction?view=aspnetcore-6.0). Every `action` method which is decorated with [`AuthorizeAttribute`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authorization.authorizeattribute?view=aspnetcore-6.0) checks whether the user is authorized and allows or forbids the request.

The Menu hides an item if the [`OnAuthorization`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iauthorizationfilter.onauthorization?view=aspnetcore-6.0) method returns
[`UnauthorizedResult`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.unauthorizedresult?view=aspnetcore-6.0).

For more information, refer to the article on [ASP.NET Core Authorization](https://docs.microsoft.com/en-us/aspnet/core/security/authorization/simple?view=aspnetcore-6.0).

The security trimming functionality can be enabled through the `SecurityTrimming` property.

```Razor HtmlHelper
    @(Html.Kendo().Menu()
        .Name("MainMenu")
        .SecurityTrimming(true)
    )
```

```Razor TagHelper
    <kendo-menu name="menu" security-trimming="true">
    </kendo-menu>
```

[This GitHub project](https://github.com/telerik/ui-for-aspnet-core-examples/blob/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Views/Menu/SecurityTrimming.cshtml) represents the usage of the `AuthorizeAttribute`.

## See Also

* [Basic Usage of the Menu HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-core/menu)
* [MenuItemBuilder Server-Side API](https://docs.telerik.com/api/kendo.mvc.ui.fluent/menuitembuilder)
* [MenuBuilder Server-Side API](https://docs.telerik.com/api/kendo.mvc.ui.fluent/menubuilder)
* [Menu Server-Side API](https://docs.telerik.com/api/menu)
