public async void OnAuthorization(AuthorizationFilterContext context)
 {
     if (Claim.Type == "KenticoAuthorize")
     {
         // Restore config
         Config      = JsonSerializer.Deserialize <KenticoAuthorizeConfiguration>(Claim.Value);
         httpContext = context.HttpContext;
         if (!AuthorizeCore())
         {
             // Custom provided redirect
             if (!string.IsNullOrWhiteSpace(Config.CustomUnauthorizedRedirect))
             {
                 context.Result = new RedirectResult(Config.CustomUnauthorizedRedirect);
             }
             else if (GetCurrentUser().UserName.Equals("public", StringComparison.InvariantCultureIgnoreCase))
             {
                 // Needs to log in, this uses ConfigureApplicationCookie's LoginPath
                 await context.HttpContext.ChallengeAsync();
             }
             else
             {
                 // Logged in, but forbidden, this uses ConfigureApplicationCookie's AccessDeniedPath
                 await context.HttpContext.ForbidAsync();
             }
         }
     }
 }
        public KenticoAuthorizeAttribute(bool CacheAuthenticationResults = true,
                                         bool CheckPageACL = false,
                                         string CustomUnauthorizedRedirect         = null,
                                         NodePermissionsEnum NodePermissionToCheck = NodePermissionsEnum.Read,
                                         string ResourceAndPermissionNames         = null,
                                         string Roles = null,
                                         bool UserAuthenticationRequired = true,
                                         string Users = null
                                         ) : base(typeof(KenticoAuthorizeFilter))
        {
            // Build Configuration
            KenticoAuthorizeConfiguration Config = new KenticoAuthorizeConfiguration()
            {
                CacheAuthenticationResults = CacheAuthenticationResults,
                CustomUnauthorizedRedirect = CustomUnauthorizedRedirect,
                CheckPageACL               = CheckPageACL,
                NodePermissionToCheck      = NodePermissionToCheck,
                ResourceAndPermissionNames = ResourceAndPermissionNames,
                Roles = Roles,
                UserAuthenticationRequired = UserAuthenticationRequired,
                Users = Users
            };

            string Serialized = JsonSerializer.Serialize(Config);

            Arguments = new object[] { new Claim("KenticoAuthorize", Serialized), };
        }