public IActionResult SetSmartOpRule([FromServices] ControlPointRegistry registry, [FromQuery] RoleBasedRule theRule)
 {
     theRule.PermissionId = DemoConst.PermissionIds.SmartOp;
     registry.RoleBasedRules.SetRoleBasedRule(theRule);
     ViewBag.Message = "SetSmartOpRule => " + theRule.Rule;
     return(View("Empty"));
 }
Beispiel #2
0
        public static void Init(ControlPointRegistry registry)
        {
            registry.SetPermission(Permissions.NeedGuest);
            registry.SetPermission(Permissions.NeedLogin);
            registry.SetPermission(Permissions.NeedAdmin);
            registry.SetPermission(Permissions.NeedSuper);
            registry.SetPermission(Permissions.Smart);

            registry.SetEndPoint(EndPoints.PageGuestOp);
            registry.SetEndPoint(EndPoints.PageLoginOp);
            registry.SetEndPoint(EndPoints.PageAdminOp);
            registry.SetEndPoint(EndPoints.PageSuperOp);
            registry.SetEndPoint(EndPoints.PageSmartOp);

            registry.SetEndPoint(EndPoints.ApiGuestOp);
            registry.SetEndPoint(EndPoints.ApiLoginOp);
            registry.SetEndPoint(EndPoints.ApiAdminOp);
            registry.SetEndPoint(EndPoints.ApiSuperOp);
            registry.SetEndPoint(EndPoints.ApiSmartOp);

            registry.SetEndPointPermission(EndPointPermission.Create(PageIds.SmartOp, PermissionIds.SmartOp));
            registry.SetEndPointPermission(EndPointPermission.Create(ApiIds.SmartOp, PermissionIds.SmartOp));

            registry.RoleBasedRules.SetRoleBasedRule(RoleBasedRule.Create(PermissionIds.GuestOp, RoleBasedRuleExpression.NeedGuest));
            registry.RoleBasedRules.SetRoleBasedRule(RoleBasedRule.Create(PermissionIds.LoginOp, RoleBasedRuleExpression.NeedLogin));
            registry.RoleBasedRules.SetRoleBasedRule(RoleBasedRule.Create(PermissionIds.AdminOp, RoleBasedRuleExpression.NeedLogin.SetNeedRoles(Roles.Admin)));
            registry.RoleBasedRules.SetRoleBasedRule(RoleBasedRule.Create(PermissionIds.SuperOp, RoleBasedRuleExpression.NeedLogin.SetNeedRoles(Roles.Super)));
        }
        public static PermissionCheckContext Create(ControlPointRegistry registry, CurrentUserContext userContext, PermissionCheckRequirement requirement, params string[] permissionIds)
        {
            var context = new PermissionCheckContext
            {
                ControlPointRegistry = registry,
                Requirement          = requirement,
                UserContext          = userContext
            };

            context.AddCheckPermissionIds(permissionIds);
            return(context);
        }
Beispiel #4
0
 public void SaveControlPointRegistry(ControlPointRegistry registry)
 {
     _registry = registry;
 }
Beispiel #5
0
 public PermissionCheckVoteService(IEnumerable <IPermissionCheckLogicProvider> providers, CurrentUserContext userContext, ControlPointRegistry registry)
 {
     _userContext = userContext;
     _registry    = registry;
     _providers   = providers.OrderBy(x => x.Order).ToList();
 }