Authorization.Kentico.MVC
13.0.0
dotnet add package Authorization.Kentico.MVC --version 13.0.0
NuGet\Install-Package Authorization.Kentico.MVC -Version 13.0.0
<PackageReference Include="Authorization.Kentico.MVC" Version="13.0.0" />
paket add Authorization.Kentico.MVC --version 13.0.0
#r "nuget: Authorization.Kentico.MVC, 13.0.0"
// Install Authorization.Kentico.MVC as a Cake Addin #addin nuget:?package=Authorization.Kentico.MVC&version=13.0.0 // Install Authorization.Kentico.MVC as a Cake Tool #tool nuget:?package=Authorization.Kentico.MVC&version=13.0.0
Kentico Authorization Attribute
For Kentico 13 .Net Core only!
Kentico Authorization Attribute for Kentico MVC, provides a [KenticoAuthorize] Attribute that you can add to your ActionResult methods that can allows for permissions on:
- User Authenticated
- User Names
- User Roles
- Page ACL Permissions (May require custom handling, see
Events
section below) - Resource/Module Permissions
It also allows for a custom Unauthorized Redirect path in case you need to specify a specific location to send unauthorized users.
Installation
- Install the
Authorization.Kentico.MVC.Core
NuGet Package to your MVC Site - Overwrite any Events if you need
- Add
[KenticoAuthorize()]
attributes to your ActionResult methods.
Usage
- Add the
[KenticoAuthorize()]
Attribute to your ActionResult and pass in any properties you wish to configure.
Events
The Authorization Module has 4 events you can hook into in order to customize it's behavior.
AuthorizeEvents.GetPage
This allows you to modify the retrieval of the current page. By default, it will try to find the page based on Kentico's Page Builder Context, then by the relative path with a match on the NodeAliasPath.
AuthorizeEvents.GetCulture
This allows you to modify the retrieval of the current culture. This is used in the GetPage logic to get the proper TreeNode. By default, It will use the PreviewCulture (if in preview), LocalizationContext.CurrentCulture, and lastly the System.Globalization.CultureInfo.CurrentCulture.Name.
AuthorizeEvents.GetUser
This allows you to modify the retrieval of the current user. By default it will use the HttpContext.User.Identity to get the UserName of the current user. Public is the default user if none found or the found user is disabled.
AuthorizeEvents.Authorizing
This allows you to modify the Authorizing logic itself. By default it will perform all the proper checks on User, Role, Module Permissions, Page ACL, and user allowed cultures. If you do overwrite, you must set SkipDefaultValidation
to true in the AuthorizingEventArgs.
Compatability
Can be used on any Kentico 13 .net Core site.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
- Antlr (>= 3.5.0.2)
- Kentico.Xperience.AspNet.Mvc5.Libraries (>= 13.0.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Options (>= 3.1.8)
- Microsoft.Owin.Security (>= 4.1.1)
- Microsoft.Owin.Security.Cookies (>= 4.1.1)
- Microsoft.Owin.Security.OAuth (>= 4.1.1)
- Microsoft.Rest.ClientRuntime (>= 2.3.20)
- Newtonsoft.Json (>= 12.0.3)
- System.Memory (>= 4.5.4)
- System.Numerics.Vectors (>= 4.5.0)
- System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
- System.ServiceModel.Primitives (>= 4.6.0)
- WebGrease (>= 1.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.