Beispiel #1
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 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"));
 }