نظرات مطالب
سفارشی سازی ASP.NET Core Identity - قسمت پنجم - سیاست‌های دسترسی پویا
سلام؛ در متد CanUserAccess کلاس SecurityTrimmingService:
 public bool CanUserAccess(ClaimsPrincipal user, string area, string controller, string action)
        {
            var currentClaimValue = $"{area}:{controller}:{action}";
            var securedControllerActions = _mvcActionsDiscoveryService.GetAllSecuredControllerActionsWithPolicy(ConstantPolicies.DynamicPermission);
            if (!securedControllerActions.SelectMany(x => x.MvcActions).Any(x => x.ActionId == currentClaimValue))
            {
                throw new KeyNotFoundException($@"The `secured` area={area}/controller={controller}/action={action} with `ConstantPolicies.DynamicPermission` policy not found. Please check you have entered the area/controller/action names correctly and also it's decorated with the correct security policy.");
            }

            if (!user.Identity.IsAuthenticated)
            {
                return false;
            }

            if (user.IsInRole(ConstantRoles.Admin))
            {
                // Admin users have access to all of the pages.
                return true;
            }

            // Check for dynamic permissions
            // A user gets its permissions claims from the `ApplicationClaimsPrincipalFactory` class automatically and it includes the role claims too.
            return user.HasClaim(claim => claim.Type == ConstantPolicies.DynamicPermissionClaimType &&
                                          claim.Value == currentClaimValue);
        }
ابتدا بررسی میشه که کاربر دارای دسترسی مورد نظر می‌باشد و سپس چک میشه که کاربر احراز هویت شده و دارای دسترسی admin می‌باشد.
آیا کاربری که دارای دسترسی Admin می‌باشد نیازی به چک کردن  HasClaim دارد؟
مثلا اگر این متد به این صورت نوشته شود مشکلی پیش میاد؟
public bool CanUserAccess(ClaimsPrincipal user, string area, string controller, string action)
        {
            if (!user.Identity.IsAuthenticated)
            {
                return false;
            }

            if (user.IsInRole(ConstantRoles.Admin))
            {
                // Admin users have access to all of the pages.
                return true;
            }

            var currentClaimValue = $"{area}:{controller}:{action}";
            var securedControllerActions = _mvcActionsDiscoveryService.GetAllSecuredControllerActionsWithPolicy(ConstantPolicies.DynamicPermission);
            if (!securedControllerActions.SelectMany(x => x.MvcActions).Any(x => x.ActionId == currentClaimValue))
            {
                throw new KeyNotFoundException($@"The `secured` area={area}/controller={controller}/action={action} with `ConstantPolicies.DynamicPermission` policy not found. Please check you have entered the area/controller/action names correctly and also it's decorated with the correct security policy.");
            }

            // Check for dynamic permissions
            // A user gets its permissions claims from the `ApplicationClaimsPrincipalFactory` class automatically and it includes the role claims too.
            return user.HasClaim(claim => claim.Type == ConstantPolicies.DynamicPermissionClaimType &&
                                          claim.Value == currentClaimValue);
        }
اشتراک‌ها
نحوه‌ی کنترل هدر Referer

HTML5 added a whole bunch of useful new values for the rel attribute, one of which is noreferrer (yes, spelt correctly this time). When this attribute is added, the browser is instructed not to set the header if the user follows the link.  

نحوه‌ی کنترل هدر Referer
اشتراک‌ها
انتشار TypeScript 4.6

Here’s a quick list of what’s new in TypeScript 4.6!

Allowing Code in Constructors Before super()
Control Flow Analysis for Destructured Discriminated Unions
Improved Recursion Depth Checks
Indexed Access Inference Improvements
Control Flow Analysis for Dependent Parameters
--target es2022
Removed Unnecessary Arguments in react-jsx
JSDoc Name Suggestions
More Syntax and Binding Errors in JavaScript
TypeScript Trace Analyzer
Breaking Changes
 

انتشار TypeScript 4.6
اشتراک‌ها
TypeScript 4.6 Beta منتشر شد

Here’s a quick list of what’s new in TypeScript 4.6!

Allowing Code in Constructors Before super()
Improved Recursion Depth Checks
Indexed Access Inference Improvements
Control Flow Analysis for Dependent Parameters
More Syntax and Binding Errors in JavaScript
TypeScript Trace Analyzer
Breaking Changes
 

TypeScript 4.6 Beta منتشر شد
اشتراک‌ها
ایجاد Responsive Layered Slider
in this tutorial you will lean how to create a responsive layered slider. The slider will have multiple slides, each slide will have multiple layers which can have a different fade in effect. The entire slider works by using just a JavaScript document and you don't have to attach any CSS style sheets to use it. Each layer will have 18 possible effects which you can use to your liking. All animations are created by inserting CSS code into the page using JavaScript.  Demo
ایجاد Responsive Layered Slider
اشتراک‌ها
کتابخانه a2d3

A set of composable and extensible Angular 2 directives for building SVGs with D3 declaritively. This library provides functionality for basic charts out of the box, but it can be easily extended to support building declarative syntaxes for just about any SVG generated by D3.  Demo

کتابخانه a2d3