Ejemplo n.º 1
0
        public override void Define(IPermissionDefinitionContext context)
        {
            var cmsGroup = context.GetGroupOrNull(CmsKitAdminPermissions.GroupName) ?? context.AddGroup(CmsKitAdminPermissions.GroupName, L("Permission:CmsKit"));


            if (GlobalFeatureManager.Instance.IsEnabled <ContentsFeature>())
            {
                var contentGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Contents.Default, L("Permission:Contents"));
                contentGroup.AddChild(CmsKitAdminPermissions.Contents.Create, L("Permission:Contents.Create"));
                contentGroup.AddChild(CmsKitAdminPermissions.Contents.Update, L("Permission:Contents.Update"));
                contentGroup.AddChild(CmsKitAdminPermissions.Contents.Delete, L("Permission:Contents.Delete"));
            }
            if (GlobalFeatureManager.Instance.IsEnabled <TagsFeature>())
            {
                var tagGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Tags.Default, L("Permission:TagManagement"));
                tagGroup.AddChild(CmsKitAdminPermissions.Tags.Create, L("Permission:TagManagement.Create"));
                tagGroup.AddChild(CmsKitAdminPermissions.Tags.Update, L("Permission:TagManagement.Update"));
                tagGroup.AddChild(CmsKitAdminPermissions.Tags.Delete, L("Permission:TagManagement.Delete"));
            }

            if (GlobalFeatureManager.Instance.IsEnabled <PagesFeature>())
            {
                var pageManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Pages.Default, L("Permission:PageManagement"));
                pageManagement.AddChild(CmsKitAdminPermissions.Pages.Create, L("Permission:PageManagement:Create"));
                pageManagement.AddChild(CmsKitAdminPermissions.Pages.Update, L("Permission:PageManagement:Update"));
                pageManagement.AddChild(CmsKitAdminPermissions.Pages.Delete, L("Permission:PageManagement:Delete"));
            }
        }
Ejemplo n.º 2
0
        public override void Define(IPermissionDefinitionContext context)
        {
            var identityGroup = context.GetGroupOrNull(Volo.Abp.Identity.IdentityPermissions.GroupName);

            if (identityGroup != null)
            {
                var userPermission = identityGroup.GetPermissionOrNull(Volo.Abp.Identity.IdentityPermissions.Users.Default);
                if (userPermission != null)
                {
                    userPermission.AddChild(IdentityPermissions.Users.ManageOrganizationUnits, L("Permission:ManageOrganizationUnits"));
                }

                var rolePermission = identityGroup.GetPermissionOrNull(Volo.Abp.Identity.IdentityPermissions.Roles.Default);
                if (rolePermission != null)
                {
                    rolePermission.AddChild(IdentityPermissions.Roles.ManageOrganizationUnits, L("Permission:ManageOrganizationUnits"));
                }

                var origanizationUnitPermission = identityGroup.AddPermission(IdentityPermissions.OrganizationUnits.Default, L("Permission:OrganizationUnitManagement"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Create, L("Permission:Create"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Update, L("Permission:Edit"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Delete, L("Permission:Delete"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.ManageRoles, L("Permission:ChangeRoles"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.ManageUsers, L("Permission:ChangeUsers"));
            }
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            var identityGroup = context.GetGroupOrNull(Volo.Abp.Identity.IdentityPermissions.GroupName);

            if (identityGroup != null)
            {
                var userPermission = identityGroup.GetPermissionOrNull(Volo.Abp.Identity.IdentityPermissions.Users.Default);
                if (userPermission != null)
                {
                    userPermission.AddChild(IdentityPermissions.Users.ManageClaims, L("Permission:ManageClaims"));
                    userPermission.AddChild(IdentityPermissions.Users.ManageOrganizationUnits, L("Permission:ManageOrganizationUnits"));
                }

                var rolePermission = identityGroup.GetPermissionOrNull(Volo.Abp.Identity.IdentityPermissions.Roles.Default);
                if (rolePermission != null)
                {
                    rolePermission.AddChild(IdentityPermissions.Roles.ManageClaims, L("Permission:ManageClaims"));
                    rolePermission.AddChild(IdentityPermissions.Roles.ManageOrganizationUnits, L("Permission:ManageOrganizationUnits"));
                }

                var origanizationUnitPermission = identityGroup.AddPermission(IdentityPermissions.OrganizationUnits.Default, L("Permission:OrganizationUnitManagement"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Create, L("Permission:Create"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Update, L("Permission:Edit"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.Delete, L("Permission:Delete"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.ManageRoles, L("Permission:ManageRoles"));
                origanizationUnitPermission.AddChild(IdentityPermissions.OrganizationUnits.ManageUsers, L("Permission:ManageUsers"));

                // 2020-10-23 修复Bug 租户用户也必须能查询自定义的声明, 管理权限只能为主机
                var identityClaimType = identityGroup.AddPermission(IdentityPermissions.IdentityClaimType.Default, L("Permission:IdentityClaimTypeManagement"));
                identityClaimType.AddChild(IdentityPermissions.IdentityClaimType.Create, L("Permission:Create"), MultiTenancySides.Host);
                identityClaimType.AddChild(IdentityPermissions.IdentityClaimType.Update, L("Permission:Edit"), MultiTenancySides.Host);
                identityClaimType.AddChild(IdentityPermissions.IdentityClaimType.Delete, L("Permission:Delete"), MultiTenancySides.Host);
            }
        }
Ejemplo n.º 4
0
        public override void Define(IPermissionDefinitionContext context)
        {
            var identityGroup = context.GetGroupOrNull(Volo.Abp.Identity.IdentityPermissions.GroupName);

            var claimTypesPermission = identityGroup.AddPermission(IdentityPermissions.ClaimTypes.Default, L("Permission:ClaimManagement"));

            claimTypesPermission.AddChild(IdentityPermissions.ClaimTypes.Create, L("Permission:Create"));
            claimTypesPermission.AddChild(IdentityPermissions.ClaimTypes.Update, L("Permission:Edit"));
            claimTypesPermission.AddChild(IdentityPermissions.ClaimTypes.Delete, L("Permission:Delete"));
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            if (context.GetGroupOrNull(BloggingPermissions.GroupName) == null)
            {
                var myGroup = context.AddGroup(BloggingPermissions.GroupName);
            }


            //Define your own permissions here. Example:
            //myGroup.AddPermission(BlogingPermissions.MyPermission1, L("Permission:MyPermission1"));
        }
Ejemplo n.º 6
0
        public override void Define(IPermissionDefinitionContext context)
        {
            var identityGroup = context.GetGroupOrNull(IdentityPermissions.GroupName);

            identityGroup.AddPermission(SettingManagementPermissions.IdentitySettingsManagement, L("SettingsManageMent"));
            var themeGroup = context.AddGroup(SettingManagementPermissions.Theme.Default, L("Theme"));

            themeGroup.AddPermission(SettingManagementPermissions.Theme.SettingsManagement, L("SettingsManageMent"));
            var accountGroup = context.AddGroup(SettingManagementPermissions.Account.Default, L("Account"));

            accountGroup.AddPermission(SettingManagementPermissions.Account.SettingsManagement, L("SettingsManageMent"));
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            PermissionGroupDefinition getGroup = context.GetGroupOrNull("TestGetGroup");

            if (getGroup == null)
            {
                getGroup = context.AddGroup("TestGetGroup");
            }
            PermissionGroupDefinition group = context.AddGroup("TestGroup");

            group.AddPermission("MyAuthorizedService1");
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            var cmsGroup = context.GetGroupOrNull(CmsKitAdminPermissions.GroupName) ?? context.AddGroup(CmsKitAdminPermissions.GroupName, L("Permission:CmsKit"));

            var contentGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Comments.Default, L("Permission:Comments"))
                               .RequireGlobalFeatures(typeof(CommentsFeature));

            contentGroup.AddChild(CmsKitAdminPermissions.Comments.Delete, L("Permission:Comments.Delete"))
            .RequireGlobalFeatures(typeof(CommentsFeature));

            var tagGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Tags.Default, L("Permission:TagManagement"))
                           .RequireGlobalFeatures(typeof(TagsFeature));

            tagGroup.AddChild(CmsKitAdminPermissions.Tags.Create, L("Permission:TagManagement.Create"))
            .RequireGlobalFeatures(typeof(TagsFeature));
            tagGroup.AddChild(CmsKitAdminPermissions.Tags.Update, L("Permission:TagManagement.Update"))
            .RequireGlobalFeatures(typeof(TagsFeature));
            tagGroup.AddChild(CmsKitAdminPermissions.Tags.Delete, L("Permission:TagManagement.Delete"))
            .RequireGlobalFeatures(typeof(TagsFeature));

            var pageManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Pages.Default, L("Permission:PageManagement"))
                                 .RequireGlobalFeatures(typeof(PagesFeature));

            pageManagement.AddChild(CmsKitAdminPermissions.Pages.Create, L("Permission:PageManagement:Create"))
            .RequireGlobalFeatures(typeof(PagesFeature));
            pageManagement.AddChild(CmsKitAdminPermissions.Pages.Update, L("Permission:PageManagement:Update"))
            .RequireGlobalFeatures(typeof(PagesFeature));
            pageManagement.AddChild(CmsKitAdminPermissions.Pages.Delete, L("Permission:PageManagement:Delete"))
            .RequireGlobalFeatures(typeof(PagesFeature));

            var blogManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.Blogs.Default, L("Permission:BlogManagement"))
                                 .RequireGlobalFeatures(typeof(BlogsFeature));

            blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Create, L("Permission:BlogManagement.Create"))
            .RequireGlobalFeatures(typeof(BlogsFeature));
            blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Update, L("Permission:BlogManagement.Update"))
            .RequireGlobalFeatures(typeof(BlogsFeature));
            blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Delete, L("Permission:BlogManagement.Delete"))
            .RequireGlobalFeatures(typeof(BlogsFeature));
            blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Features, L("Permission:BlogManagement.Features"))
            .RequireGlobalFeatures(typeof(BlogsFeature));

            var blogPostManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.BlogPosts.Default, L("Permission:BlogPostManagement"))
                                     .RequireGlobalFeatures(typeof(BlogsFeature));

            blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Create, L("Permission:BlogPostManagement.Create"))
            .RequireGlobalFeatures(typeof(BlogsFeature));
            blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Update, L("Permission:BlogPostManagement.Update"))
            .RequireGlobalFeatures(typeof(BlogsFeature));
            blogPostManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Delete, L("Permission:BlogPostManagement.Delete"))
            .RequireGlobalFeatures(typeof(BlogsFeature));
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            // TODO: 硬编码权限名称还是引用 Volo.Abp.FeatureManagement.Application.Contracts?

            var identityServerGroup = context.GetGroupOrNull(ClientFeaturePermissionNames.GroupName);

            Check.NotNull(identityServerGroup, $"Permissions:{ClientFeaturePermissionNames.GroupName}");

            identityServerGroup
            .AddPermission(
                name: ClientFeaturePermissionNames.ManageClientFeatures,
                displayName: L("Permissions:ManageClientFeatures"),
                multiTenancySide: Volo.Abp.MultiTenancy.MultiTenancySides.Host);
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            // TODO: 身份认证服务器应该只能主机管辖
            // 增加 MultiTenancySides.Host
            // var identityServerGroup = context.AddGroup(AbpIdentityServerPermissions.GroupName, L("Permissions:IdentityServer"), MultiTenancySides.Host);

            // 与 LINGYUN.Abp.FeatureManagement.Client 模块搭配,这样干可以不依赖于模块优先级
            var identityServerGroup = context.GetGroupOrNull(AbpIdentityServerPermissions.GroupName);

            if (identityServerGroup == null)
            {
                identityServerGroup = context
                                      .AddGroup(
                    name: AbpIdentityServerPermissions.GroupName,
                    displayName: L("Permissions:IdentityServer"),
                    multiTenancySide: MultiTenancySides.Host);
            }
            // 客户端权限
            var clientPermissions = identityServerGroup.AddPermission(AbpIdentityServerPermissions.Clients.Default, L("Permissions:Clients"), MultiTenancySides.Host);

            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.Create, L("Permissions:Create"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.Update, L("Permissions:Update"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.Clone, L("Permissions:Clone"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.Delete, L("Permissions:Delete"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.ManagePermissions, L("Permissions:ManagePermissions"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.ManageClaims, L("Permissions:ManageClaims"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.ManageSecrets, L("Permissions:ManageSecrets"), MultiTenancySides.Host);
            clientPermissions.AddChild(AbpIdentityServerPermissions.Clients.ManageProperties, L("Permissions:ManageProperties"), MultiTenancySides.Host);

            // Api资源权限
            var apiResourcePermissions = identityServerGroup.AddPermission(AbpIdentityServerPermissions.ApiResources.Default, L("Permissions:ApiResources"), MultiTenancySides.Host);

            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.Create, L("Permissions:Create"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.Update, L("Permissions:Update"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.Delete, L("Permissions:Delete"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.ManageClaims, L("Permissions:ManageClaims"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.ManageSecrets, L("Permissions:ManageSecrets"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.ManageProperties, L("Permissions:ManageProperties"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(AbpIdentityServerPermissions.ApiResources.ManageScopes, L("Permissions:ManageScopes"), MultiTenancySides.Host);

            // 身份资源权限
            var identityResourcePermissions = identityServerGroup.AddPermission(AbpIdentityServerPermissions.IdentityResources.Default, L("Permissions:IdentityResources"), MultiTenancySides.Host);

            identityResourcePermissions.AddChild(AbpIdentityServerPermissions.IdentityResources.Create, L("Permissions:Create"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(AbpIdentityServerPermissions.IdentityResources.Update, L("Permissions:Update"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(AbpIdentityServerPermissions.IdentityResources.Delete, L("Permissions:Delete"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(AbpIdentityServerPermissions.IdentityResources.ManageClaims, L("Permissions:ManageClaims"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(AbpIdentityServerPermissions.IdentityResources.ManageProperties, L("Permissions:ManageProperties"), MultiTenancySides.Host);
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            var getGroup = context.GetGroupOrNull("TestGetGroup");

            if (getGroup == null)
            {
                getGroup = context.AddGroup("TestGetGroup");
            }

            var group = context.AddGroup("TestGroup");

            group.AddPermission("MyAuthorizedService1");

            //group.GetPermissionOrNull("MyAuthorizedService1").ShouldNotBeNull();

            //context.RemoveGroup("TestGetGroup");
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            var identityServerGroup = context.GetGroupOrNull(IdentityServerPermissions.GroupName);

            if (identityServerGroup == null)
            {
                identityServerGroup = context
                                      .AddGroup(
                    name: IdentityServerPermissions.GroupName,
                    displayName: L("Permissions:IdentityServer"),
                    multiTenancySide: MultiTenancySides.Host);
            }
            // 客户端权限
            var clientPermissions = identityServerGroup.AddPermission(IdentityServerPermissions.Clients.Default, L("Permissions:Clients"), MultiTenancySides.Host);

            clientPermissions.AddChild(IdentityServerPermissions.Clients.Create, L("Permissions:Create"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.Update, L("Permissions:Update"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.Clone, L("Permissions:Clone"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.Delete, L("Permissions:Delete"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.ManagePermissions, L("Permissions:ManagePermissions"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.ManageClaims, L("Permissions:ManageClaims"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.ManageSecrets, L("Permissions:ManageSecrets"), MultiTenancySides.Host);
            clientPermissions.AddChild(IdentityServerPermissions.Clients.ManageProperties, L("Permissions:ManageProperties"), MultiTenancySides.Host);

            // Api资源权限
            var apiResourcePermissions = identityServerGroup.AddPermission(IdentityServerPermissions.ApiResources.Default, L("Permissions:ApiResources"), MultiTenancySides.Host);

            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.Create, L("Permissions:Create"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.Update, L("Permissions:Update"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.Delete, L("Permissions:Delete"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.ManageClaims, L("Permissions:ManageClaims"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.ManageSecrets, L("Permissions:ManageSecrets"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.ManageProperties, L("Permissions:ManageProperties"), MultiTenancySides.Host);
            apiResourcePermissions.AddChild(IdentityServerPermissions.ApiResources.ManageScopes, L("Permissions:ManageScopes"), MultiTenancySides.Host);

            // 身份资源权限
            var identityResourcePermissions = identityServerGroup.AddPermission(IdentityServerPermissions.IdentityResources.Default, L("Permissions:IdentityResources"), MultiTenancySides.Host);

            identityResourcePermissions.AddChild(IdentityServerPermissions.IdentityResources.Create, L("Permissions:Create"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(IdentityServerPermissions.IdentityResources.Update, L("Permissions:Update"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(IdentityServerPermissions.IdentityResources.Delete, L("Permissions:Delete"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(IdentityServerPermissions.IdentityResources.ManageClaims, L("Permissions:ManageClaims"), MultiTenancySides.Host);
            identityResourcePermissions.AddChild(IdentityServerPermissions.IdentityResources.ManageProperties, L("Permissions:ManageProperties"), MultiTenancySides.Host);
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            var identityServerGroup = context.GetGroupOrNull(ClientFeaturePermissionNames.GroupName);

            if (identityServerGroup == null)
            {
                identityServerGroup = context
                                      .AddGroup(
                    name: ClientFeaturePermissionNames.GroupName,
                    displayName: L("Permissions:IdentityServer"),
                    multiTenancySide: Volo.Abp.MultiTenancy.MultiTenancySides.Host);
            }
            identityServerGroup
            .AddPermission(
                name: ClientFeaturePermissionNames.Clients.ManageFeatures,
                displayName: L("Permissions:ManageFeatures"),
                multiTenancySide: Volo.Abp.MultiTenancy.MultiTenancySides.Host)
            .WithProviders(ClientPermissionValueProvider.ProviderName);
        }
        public override void Define(IPermissionDefinitionContext context)
        {
            var getGroup = context.GetGroupOrNull("TestGetGroup");

            if (getGroup == null)
            {
                getGroup = context.AddGroup("TestGetGroup");
            }

            var group = context.AddGroup("TestGroup");

            group.AddPermission("MyAuthorizedService1");

            group.AddPermission("MyPermission1").AddStateProviders(new TestRequireEditionPermissionStateProvider());
            group.AddPermission("MyPermission2");

            group.GetPermissionOrNull("MyAuthorizedService1").ShouldNotBeNull();

            context.RemoveGroup("TestGetGroup");
        }