From 2f83c1420a731105527709c83ad3ff0880abae53 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Mon, 27 May 2024 15:28:41 -0700 Subject: [PATCH 1/6] Mark duplicate permissions as Obsolete --- .../OrchardCore.Apis.GraphQL/Permissions.cs | 9 +- .../OrchardCore.AuditTrail/Permissions.cs | 8 +- .../OrchardCore.Contents/Permissions.cs | 101 +++++++++++------- .../OrchardCore.Deployment/AdminMenu.cs | 6 +- .../Controllers/DeploymentPlanController.cs | 18 ++-- .../Controllers/ExportFileController.cs | 2 +- .../Controllers/ImportController.cs | 8 +- .../Controllers/StepController.cs | 12 +-- .../DeploymentPlanService.cs | 6 +- .../OrchardCore.Deployment/Permissions.cs | 12 ++- .../GoogleAnalyticsPermissionsProvider.cs | 4 +- .../NotificationPermissionsProvider.cs | 4 +- .../OrchardCore.Roles/Permissions.cs | 6 ++ .../Permissions.cs | 9 +- .../OrchardCore.Users/UserRolePermissions.cs | 4 +- .../Apis/GraphQL/Blog/BlogPostTests.cs | 29 ++--- 16 files changed, 149 insertions(+), 89 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs index 0679fc6c51c..dea7bc32dcf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Security.Permissions; @@ -6,13 +7,17 @@ namespace OrchardCore.Apis.GraphQL; public class Permissions : IPermissionProvider { + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ExecuteGraphQLMutations'.")] public static readonly Permission ExecuteGraphQLMutations = CommonPermissions.ExecuteGraphQLMutations; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ExecuteGraphQL'.")] public static readonly Permission ExecuteGraphQL = CommonPermissions.ExecuteGraphQL; private readonly IEnumerable _allPermissions = [ - ExecuteGraphQL, - ExecuteGraphQLMutations, + CommonPermissions.ExecuteGraphQL, + CommonPermissions.ExecuteGraphQLMutations, ]; public Task> GetPermissionsAsync() diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs index a9d7968c807..15589780a13 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Security.Permissions; @@ -6,13 +7,16 @@ namespace OrchardCore.AuditTrail; public class Permissions : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'AuditTrailPermissions.ViewAuditTrail'.")] public static readonly Permission ViewAuditTrail = AuditTrailPermissions.ViewAuditTrail; + + [Obsolete("This property will be removed in future release. Instead use 'AuditTrailPermissions.ManageAuditTrailSettings'.")] public static readonly Permission ManageAuditTrailSettings = AuditTrailPermissions.ManageAuditTrailSettings; private readonly IEnumerable _allPermissions = [ - ViewAuditTrail, - ManageAuditTrailSettings, + AuditTrailPermissions.ViewAuditTrail, + AuditTrailPermissions.ManageAuditTrailSettings, ]; public Task> GetPermissionsAsync() diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs index 7edb0f806f2..007886866c6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Security.Permissions; @@ -11,44 +12,72 @@ public class Permissions : IPermissionProvider // EditOwn is the permission that is ultimately required to create new content. See how the Create() method is implemented in the AdminController. + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PublishContent'.")] public static readonly Permission PublishContent = CommonPermissions.PublishContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PublishOwnContent'.")] public static readonly Permission PublishOwnContent = CommonPermissions.PublishOwnContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.EditContent'.")] public static readonly Permission EditContent = CommonPermissions.EditContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.EditOwnContent'.")] public static readonly Permission EditOwnContent = CommonPermissions.EditOwnContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.DeleteContent'.")] public static readonly Permission DeleteContent = CommonPermissions.DeleteContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.DeleteOwnContent'.")] public static readonly Permission DeleteOwnContent = CommonPermissions.DeleteOwnContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ViewContent'.")] public static readonly Permission ViewContent = CommonPermissions.ViewContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ViewOwnContent'.")] public static readonly Permission ViewOwnContent = CommonPermissions.ViewOwnContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PreviewContent'.")] public static readonly Permission PreviewContent = CommonPermissions.PreviewContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PreviewOwnContent'.")] public static readonly Permission PreviewOwnContent = CommonPermissions.PreviewOwnContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.CloneContent'.")] public static readonly Permission CloneContent = CommonPermissions.CloneContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.CloneOwnContent'.")] public static readonly Permission CloneOwnContent = CommonPermissions.CloneOwnContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ListContent'.")] public static readonly Permission ListContent = CommonPermissions.ListContent; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.EditContentOwner'.")] public static readonly Permission EditContentOwner = CommonPermissions.EditContentOwner; + public static readonly Permission AccessContentApi = new("AccessContentApi", "Access content via the api"); private readonly IEnumerable _readerPermissions = [ - ViewContent, + CommonPermissions.ViewContent, ]; private readonly IEnumerable _allPermissions = [ - EditContent, - EditOwnContent, - PublishContent, - PublishOwnContent, - DeleteContent, - DeleteOwnContent, - ViewContent, - ViewOwnContent, - PreviewContent, - PreviewOwnContent, - CloneContent, - CloneOwnContent, + CommonPermissions.EditContent, + CommonPermissions.EditOwnContent, + CommonPermissions.PublishContent, + CommonPermissions.PublishOwnContent, + CommonPermissions.DeleteContent, + CommonPermissions.DeleteOwnContent, + CommonPermissions.ViewContent, + CommonPermissions.ViewOwnContent, + CommonPermissions.PreviewContent, + CommonPermissions.PreviewOwnContent, + CommonPermissions.CloneContent, + CommonPermissions.CloneOwnContent, AccessContentApi, - ListContent, - EditContentOwner, + CommonPermissions.ListContent, + CommonPermissions.EditContentOwner, ]; public Task> GetPermissionsAsync() @@ -61,14 +90,14 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Administrator, Permissions = [ - PublishContent, - EditContent, - DeleteContent, - PreviewContent, - CloneContent, + CommonPermissions.PublishContent, + CommonPermissions.EditContent, + CommonPermissions.DeleteContent, + CommonPermissions.PreviewContent, + CommonPermissions.CloneContent, AccessContentApi, - ListContent, - EditContentOwner, + CommonPermissions.ListContent, + CommonPermissions.EditContentOwner, ], }, new PermissionStereotype @@ -76,12 +105,12 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Editor, Permissions = [ - PublishContent, - EditContent, - DeleteContent, - PreviewContent, - CloneContent, - ListContent, + CommonPermissions.PublishContent, + CommonPermissions.EditContent, + CommonPermissions.DeleteContent, + CommonPermissions.PreviewContent, + CommonPermissions.CloneContent, + CommonPermissions.ListContent, ], }, new PermissionStereotype @@ -89,11 +118,11 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Author, Permissions = [ - PublishOwnContent, - EditOwnContent, - DeleteOwnContent, - PreviewOwnContent, - CloneOwnContent, + CommonPermissions.PublishOwnContent, + CommonPermissions.EditOwnContent, + CommonPermissions.DeleteOwnContent, + CommonPermissions.PreviewOwnContent, + CommonPermissions.CloneOwnContent, ], }, new PermissionStereotype @@ -101,9 +130,9 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Contributor, Permissions = [ - EditOwnContent, - PreviewOwnContent, - CloneOwnContent, + CommonPermissions.EditOwnContent, + CommonPermissions.PreviewOwnContent, + CommonPermissions.CloneOwnContent, ], }, new PermissionStereotype diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs index 0fec8dc7bf5..c31c8dc7921 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs @@ -25,17 +25,17 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Add(S["Import/Export"], S["Import/Export"].PrefixPosition(), import => import .Add(S["Deployment Plans"], S["Deployment Plans"].PrefixPosition(), deployment => deployment .Action("Index", "DeploymentPlan", "OrchardCore.Deployment") - .Permission(Permissions.Export) + .Permission(CommonPermissions.Export) .LocalNav() ) .Add(S["Package Import"], S["Package Import"].PrefixPosition(), deployment => deployment .Action("Index", "Import", "OrchardCore.Deployment") - .Permission(Permissions.Import) + .Permission(CommonPermissions.Import) .LocalNav() ) .Add(S["JSON Import"], S["JSON Import"].PrefixPosition(), deployment => deployment .Action("Json", "Import", "OrchardCore.Deployment") - .Permission(Permissions.Import) + .Permission(CommonPermissions.Import) .LocalNav() ) ) diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/DeploymentPlanController.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/DeploymentPlanController.cs index 73d0435b812..3556a0f7edc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/DeploymentPlanController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/DeploymentPlanController.cs @@ -65,12 +65,12 @@ public DeploymentPlanController( public async Task Index(ContentOptions options, PagerParameters pagerParameters) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } - if (!await _authorizationService.AuthorizeAsync(User, Permissions.Export)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.Export)) { return Forbid(); } @@ -129,7 +129,7 @@ public ActionResult IndexFilterPOST(DeploymentPlanIndexViewModel model) [FormValueRequired("submit.BulkAction")] public async Task IndexBulkActionPOST(ContentOptions options, IEnumerable itemIds) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -158,7 +158,7 @@ public async Task IndexBulkActionPOST(ContentOptions options, IEnu public async Task Display(long id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -199,7 +199,7 @@ public async Task Display(long id) public async Task Create() { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -212,7 +212,7 @@ public async Task Create() [HttpPost] public async Task Create(CreateDeploymentPlanViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -246,7 +246,7 @@ public async Task Create(CreateDeploymentPlanViewModel model) public async Task Edit(long id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -270,7 +270,7 @@ public async Task Edit(long id) [HttpPost] public async Task Edit(EditDeploymentPlanViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -316,7 +316,7 @@ public async Task Edit(EditDeploymentPlanViewModel model) [HttpPost] public async Task Delete(long id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ExportFileController.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ExportFileController.cs index 42dabf53c9a..b2cfaa3f843 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ExportFileController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ExportFileController.cs @@ -36,7 +36,7 @@ public ExportFileController( [DeleteFileResultFilter] public async Task Execute(long id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.Export)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.Export)) { return Forbid(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ImportController.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ImportController.cs index 87ff0a3874a..3d68c8bc214 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ImportController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/ImportController.cs @@ -50,7 +50,7 @@ IStringLocalizer stringLocalizer public async Task Index() { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.Import)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.Import)) { return Forbid(); } @@ -61,7 +61,7 @@ public async Task Index() [HttpPost] public async Task Import(IFormFile importedPackage) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.Import)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.Import)) { return Forbid(); } @@ -133,7 +133,7 @@ public async Task Import(IFormFile importedPackage) public async Task Json() { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.Import)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.Import)) { return Forbid(); } @@ -144,7 +144,7 @@ public async Task Json() [HttpPost] public async Task Json(ImportJsonViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.Import)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.Import)) { return Forbid(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/StepController.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/StepController.cs index 1818f16fbd4..db7bc2f1326 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/StepController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Controllers/StepController.cs @@ -47,7 +47,7 @@ public StepController( [Admin("DeploymentPlan/{id}/Step/Create", "DeploymentPlanCreateStep")] public async Task Create(long id, string type) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -85,7 +85,7 @@ public async Task Create(long id, string type) [HttpPost] public async Task Create(EditDeploymentPlanStepViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -126,7 +126,7 @@ public async Task Create(EditDeploymentPlanStepViewModel model) [Admin("DeploymentPlan/{id}/Step/{stepId}/Edit", "DeploymentPlanEditStep")] public async Task Edit(long id, string stepId) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -162,7 +162,7 @@ public async Task Edit(long id, string stepId) [HttpPost] public async Task Edit(EditDeploymentPlanStepViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -202,7 +202,7 @@ public async Task Edit(EditDeploymentPlanStepViewModel model) [Admin("DeploymentPlan/{id}/Step/{stepId}/Delete", "DeploymentPlanDeleteStep")] public async Task Delete(long id, string stepId) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } @@ -232,7 +232,7 @@ public async Task Delete(long id, string stepId) [HttpPost] public async Task UpdateOrder(long id, int oldIndex, int newIndex) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageDeploymentPlan)) { return Forbid(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/DeploymentPlanService.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/DeploymentPlanService.cs index bd79c533b3b..625a155fb3f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/DeploymentPlanService.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/DeploymentPlanService.cs @@ -43,8 +43,8 @@ public async Task DoesUserHavePermissionsAsync() { var user = _httpContextAccessor.HttpContext.User; - var result = await _authorizationService.AuthorizeAsync(user, Permissions.ManageDeploymentPlan) && - await _authorizationService.AuthorizeAsync(user, Permissions.Export); + var result = await _authorizationService.AuthorizeAsync(user, CommonPermissions.ManageDeploymentPlan) && + await _authorizationService.AuthorizeAsync(user, CommonPermissions.Export); return result; } @@ -53,7 +53,7 @@ public async Task DoesUserHaveExportPermissionAsync() { var user = _httpContextAccessor.HttpContext.User; - var result = await _authorizationService.AuthorizeAsync(user, Permissions.Export); + var result = await _authorizationService.AuthorizeAsync(user, CommonPermissions.Export); return result; } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs index 9575653bf9a..376fdd2fdb9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Security.Permissions; @@ -6,15 +7,20 @@ namespace OrchardCore.Deployment; public class Permissions : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ManageDeploymentPlan'.")] public static readonly Permission ManageDeploymentPlan = CommonPermissions.ManageDeploymentPlan; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.Export'.")] public static readonly Permission Export = CommonPermissions.Export; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.Import'.")] public static readonly Permission Import = CommonPermissions.Import; private readonly IEnumerable _allPermissions = [ - Import, - Export, - ManageDeploymentPlan, + CommonPermissions.Import, + CommonPermissions.Export, + CommonPermissions.ManageDeploymentPlan, ]; public Task> GetPermissionsAsync() diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs index 81ff3e6cd88..4d752b1e83a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Security.Permissions; @@ -6,11 +7,12 @@ namespace OrchardCore.Google; public class GoogleAnalyticsPermissionsProvider : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'Permissions.ManageGoogleAnalytics'.")] public static readonly Permission ManageGoogleAnalytics = Permissions.ManageGoogleAnalytics; private readonly IEnumerable _allPermissions = [ - ManageGoogleAnalytics, + Permissions.ManageGoogleAnalytics, ]; public Task> GetPermissionsAsync() diff --git a/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs index 23537016cae..8671aac56b7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Security.Permissions; @@ -6,11 +7,12 @@ namespace OrchardCore.Notifications; public class NotificationPermissionsProvider : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'NotificationPermissions.ManageNotifications'.")] public static readonly Permission ManageNotifications = NotificationPermissions.ManageNotifications; private readonly IEnumerable _allPermissions = [ - ManageNotifications, + NotificationPermissions.ManageNotifications, ]; public Task> GetPermissionsAsync() diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs index 190e30d1fcf..4dc94c9108a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -9,8 +10,13 @@ namespace OrchardCore.Roles; public class Permissions : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ManageRoles'.")] public static readonly Permission ManageRoles = CommonPermissions.ManageRoles; + + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.AssignRoles'.")] public static readonly Permission AssignRoles = CommonPermissions.AssignRoles; + + [Obsolete("This property will be removed in future release. Instead use 'StandardPermissions.SiteOwner'.")] public static readonly Permission SiteOwner = StandardPermissions.SiteOwner; private readonly IRoleService _roleService; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs index 468c9ef238b..5f4bda93ac5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Search.Elasticsearch.Core.Services; @@ -7,8 +8,10 @@ namespace OrchardCore.Search.Elasticsearch; public class Permissions : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'ElasticsearchIndexPermissionHelper.ManageElasticIndexes'.")] public static readonly Permission ManageElasticIndexes = ElasticsearchIndexPermissionHelper.ManageElasticIndexes; - public static readonly Permission QueryElasticApi = new("QueryElasticsearchApi", "Query Elasticsearch Api", new[] { ManageElasticIndexes }); + + public static readonly Permission QueryElasticApi = new("QueryElasticsearchApi", "Query Elasticsearch Api", new[] { ElasticsearchIndexPermissionHelper.ManageElasticIndexes }); private readonly ElasticIndexSettingsService _elasticIndexSettingsService; @@ -21,7 +24,7 @@ public async Task> GetPermissionsAsync() { var permissions = new List() { - ManageElasticIndexes, + ElasticsearchIndexPermissionHelper.ManageElasticIndexes, QueryElasticApi, }; @@ -42,7 +45,7 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Administrator, Permissions = [ - ManageElasticIndexes, + ElasticsearchIndexPermissionHelper.ManageElasticIndexes, ], }, new PermissionStereotype diff --git a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs index 72e9a3bdf8a..b3d9e3319c3 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -8,6 +9,7 @@ namespace OrchardCore.Users; public class UserRolePermissions : IPermissionProvider { + [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.AssignRoleToUsers'.")] public static readonly Permission AssignRoleToUsers = CommonPermissions.AssignRoleToUsers; private readonly IRoleService _roleService; @@ -21,7 +23,7 @@ public async Task> GetPermissionsAsync() { var permissions = new List() { - AssignRoleToUsers, + CommonPermissions.AssignRoleToUsers, }; var roleNames = (await _roleService.GetRoleNamesAsync()) diff --git a/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs b/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs index df8292c826f..a7ff667f377 100644 --- a/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs +++ b/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs @@ -1,4 +1,5 @@ using System.Text.Json.Nodes; +using OrchardCore.Apis.GraphQL; using OrchardCore.Autoroute.Models; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement; @@ -217,11 +218,11 @@ public async Task ShouldReturnBlogsWithViewBlogContentPermission() .WithPermissionsContext(new PermissionsContext { UsePermissionsContext = true, - AuthorizedPermissions = new[] - { - GraphQLApi.Permissions.ExecuteGraphQL, - Contents.Permissions.ViewContent, - }, + AuthorizedPermissions = + [ + CommonPermissions.ExecuteGraphQL, + Contents.CommonPermissions.ViewContent, + ], }); await context.InitializeAsync(); @@ -242,11 +243,11 @@ public async Task ShouldNotReturnBlogsWithViewOwnBlogContentPermission() .WithPermissionsContext(new PermissionsContext { UsePermissionsContext = true, - AuthorizedPermissions = new[] - { - GraphQLApi.Permissions.ExecuteGraphQL, - Contents.Permissions.ViewOwnContent, - }, + AuthorizedPermissions = + [ + CommonPermissions.ExecuteGraphQL, + Contents.CommonPermissions.ViewOwnContent, + ], }); await context.InitializeAsync(); @@ -267,10 +268,10 @@ public async Task ShouldNotReturnBlogsWithoutViewBlogContentPermission() .WithPermissionsContext(new PermissionsContext { UsePermissionsContext = true, - AuthorizedPermissions = new[] - { - GraphQLApi.Permissions.ExecuteGraphQL, - }, + AuthorizedPermissions = + [ + CommonPermissions.ExecuteGraphQL, + ], }); await context.InitializeAsync(); From 43fba1870b77c34dbd67dd178d0f81aa19c610f5 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 28 May 2024 09:48:49 -0700 Subject: [PATCH 2/6] address all warnings --- .../OrchardCore.Apis.GraphQL/AdminMenu.cs | 2 +- .../GraphQLMiddleware.cs | 2 +- .../OrchardCore.Apis.GraphQL/Permissions.cs | 2 +- .../RequiresPermissionValidationRule.cs | 2 +- .../OrchardCore.Contents/AdminMenu.cs | 2 +- .../Controllers/AdminController.cs | 2 +- .../OrchardCore.Roles/AdminMenu.cs | 2 +- .../Controllers/AdminController.cs | 14 ++++++------ .../OrchardCore.Roles/Permissions.cs | 10 ++++----- .../AdminMenu.cs | 4 ++-- .../Controllers/AdminController.cs | 22 +++++++++---------- ...tentPartFieldIndexSettingsDisplayDriver.cs | 4 ++-- ...ntentTypePartIndexSettingsDisplayDriver.cs | 4 ++-- .../Drivers/ElasticSettingsDisplayDriver.cs | 4 ++-- 14 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs index bb84d4f87e4..b04bd82c25f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs @@ -24,7 +24,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Add(S["Configuration"], configuration => configuration .Add(S["GraphiQL"], S["GraphiQL"].PrefixPosition(), graphiQL => graphiQL .Action("Index", "Admin", "OrchardCore.Apis.GraphQL") - .Permission(Permissions.ExecuteGraphQL) + .Permission(CommonPermissions.ExecuteGraphQL) .LocalNav() ) ); diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs index ac1436e40c9..83d167d995c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/GraphQLMiddleware.cs @@ -64,7 +64,7 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next) context.User = authenticateResult.Principal; } var authorizationService = context.RequestServices.GetService(); - var authorized = await authorizationService.AuthorizeAsync(context.User, Permissions.ExecuteGraphQL); + var authorized = await authorizationService.AuthorizeAsync(context.User, CommonPermissions.ExecuteGraphQL); if (authorized) { diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs index dea7bc32dcf..b75c5d1d923 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs @@ -30,7 +30,7 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Administrator, Permissions = [ - ExecuteGraphQLMutations, + CommonPermissions.ExecuteGraphQLMutations, ], }, ]; diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs index 7940a9a10d6..82e30290bd8 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/ValidationRules/RequiresPermissionValidationRule.cs @@ -59,7 +59,7 @@ public async ValueTask ValidateAsync(ValidationContext validationC private async Task AuthorizeOperationAsync(ASTNode node, ValidationContext validationContext, GraphQLUserContext userContext, OperationType? operationType, string operationName) { - if (operationType == OperationType.Mutation && !(await _authorizationService.AuthorizeAsync(userContext.User, Permissions.ExecuteGraphQLMutations))) + if (operationType == OperationType.Mutation && !(await _authorizationService.AuthorizeAsync(userContext.User, CommonPermissions.ExecuteGraphQLMutations))) { validationContext.ReportError(new ValidationError( validationContext.Document.Source, diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs index 6d96db5449b..188aad57cb9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs @@ -75,7 +75,7 @@ await content.AddAsync(S["Content Items"], S["Content Items"].PrefixPosition(), { if (!await _authorizationService.AuthorizeContentTypeDefinitionsAsync(context.User, CommonPermissions.ListContent, contentTypes, _contentManager)) { - contentItems.Permission(Permissions.ListContent); + contentItems.Permission(CommonPermissions.ListContent); } contentItems.Action(nameof(AdminController.List), typeof(AdminController).ControllerName(), _routeValues); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs index 914cc0f6894..62a68c637cf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs @@ -147,7 +147,7 @@ public async Task List( new SelectListItem(S["All versions"], nameof(ContentsStatus.AllVersions)), ]; - if (await IsAuthorizedAsync(Permissions.ListContent)) + if (await IsAuthorizedAsync(CommonPermissions.ListContent)) { options.ContentStatuses.Insert(1, new SelectListItem(S["Owned by me"], nameof(ContentsStatus.Owner))); } diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs index 3d86d657a5c..a156ea784bd 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs @@ -25,7 +25,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Add(S["Roles"], S["Roles"].PrefixPosition(), roles => roles .AddClass("roles").Id("roles") .Action("Index", "Admin", "OrchardCore.Roles") - .Permission(Permissions.ManageRoles) + .Permission(CommonPermissions.ManageRoles) .LocalNav() ) ); diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs index 1fff5e39075..2eec27f675d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs @@ -62,7 +62,7 @@ public AdminController( public async Task Index() { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRoles)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageRoles)) { return Forbid(); } @@ -79,7 +79,7 @@ public async Task Index() public async Task Create() { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRoles)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageRoles)) { return Forbid(); } @@ -92,7 +92,7 @@ public async Task Create() [HttpPost] public async Task Create(CreateRoleViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRoles)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageRoles)) { return Forbid(); } @@ -137,7 +137,7 @@ public async Task Create(CreateRoleViewModel model) [HttpPost] public async Task Delete(string id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRoles)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageRoles)) { return Forbid(); } @@ -172,7 +172,7 @@ public async Task Delete(string id) public async Task Edit(string id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRoles)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageRoles)) { return Forbid(); } @@ -200,7 +200,7 @@ public async Task Edit(string id) [HttpPost, ActionName(nameof(Edit))] public async Task EditPost(string id, string roleDescription) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRoles)) + if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ManageRoles)) { return Forbid(); } @@ -247,7 +247,7 @@ private async Task>> Get { var installedPermissions = new Dictionary>(); var enabledFeatures = await _shellFeaturesManager.GetEnabledFeaturesAsync(); - + foreach (var permissionProvider in _permissionProviders) { // Two features could use the same permission. diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs index 4dc94c9108a..34aa0a0613d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs @@ -34,9 +34,9 @@ public async Task> GetPermissionsAsync() var list = new List(roleNames.Count + 3) { - ManageRoles, - AssignRoles, - SiteOwner, + CommonPermissions.ManageRoles, + CommonPermissions.AssignRoles, + StandardPermissions.SiteOwner, }; foreach (var roleName in roleNames) @@ -54,8 +54,8 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Administrator, Permissions = [ - ManageRoles, - SiteOwner, + CommonPermissions.ManageRoles, + StandardPermissions.SiteOwner, ], }, ]; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs index 91f64af45b4..e9ab0505f36 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs @@ -24,7 +24,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Action("Index", "Admin", "OrchardCore.Search.Elasticsearch") .AddClass("elasticsearchindices") .Id("elasticsearchindices") - .Permission(Permissions.ManageElasticIndexes) + .Permission(ElasticsearchIndexPermissionHelper.ManageElasticIndexes) .LocalNav() ) ) @@ -33,7 +33,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Action("Query", "Admin", "OrchardCore.Search.Elasticsearch") .AddClass("elasticsearchquery") .Id("elasticsearchquery") - .Permission(Permissions.ManageElasticIndexes) + .Permission(ElasticsearchIndexPermissionHelper.ManageElasticIndexes) .LocalNav() ) ) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs index 3f0022a270d..12348b8319f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs @@ -105,7 +105,7 @@ public AdminController( public async Task Index(ContentOptions options, PagerParameters pagerParameters) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -174,7 +174,7 @@ public async Task Edit(string indexName = null) var IsCreate = string.IsNullOrWhiteSpace(indexName); var settings = new ElasticIndexSettings(); - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -213,7 +213,7 @@ public async Task Edit(string indexName = null) [HttpPost, ActionName(nameof(Edit))] public async Task EditPost(ElasticIndexSettingsViewModel model, string[] indexedContentTypes) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -313,7 +313,7 @@ public async Task EditPost(ElasticIndexSettingsViewModel model, st [HttpPost] public async Task Reset(string id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -339,7 +339,7 @@ public async Task Reset(string id) [HttpPost] public async Task Rebuild(string id) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -377,7 +377,7 @@ public async Task Rebuild(string id) [HttpPost] public async Task Delete(ElasticIndexSettingsViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -411,7 +411,7 @@ public async Task Delete(ElasticIndexSettingsViewModel model) [HttpPost] public async Task ForceDelete(ElasticIndexSettingsViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -439,7 +439,7 @@ public async Task ForceDelete(ElasticIndexSettingsViewModel model) public async Task Mappings(string indexName) { var mappings = await _elasticIndexManager.GetIndexMappings(indexName); - var formattedJson = JNode.Parse(mappings).ToJsonString(System.Text.Json.JOptions.Indented); + var formattedJson = JNode.Parse(mappings).ToJsonString(JOptions.Indented); return View(new MappingsViewModel { IndexName = _elasticIndexManager.GetFullIndexName(indexName), @@ -449,7 +449,7 @@ public async Task Mappings(string indexName) public async Task SyncSettings() { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -476,7 +476,7 @@ public async Task Query(string indexName, string query) [HttpPost] public async Task Query(AdminQueryViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } @@ -546,7 +546,7 @@ public async Task Query(AdminQueryViewModel model) [FormValueRequired("submit.BulkAction")] public async Task IndexPost(ContentOptions options, IEnumerable itemIds) { - if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return Forbid(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs index 367bfd16664..568b9d40841 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs @@ -23,7 +23,7 @@ public ContentPartFieldIndexSettingsDisplayDriver(IAuthorizationService authoriz public override async Task EditAsync(ContentPartFieldDefinition contentPartFieldDefinition, IUpdateModel updater) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return null; } @@ -36,7 +36,7 @@ public override async Task EditAsync(ContentPartFieldDefinition public override async Task UpdateAsync(ContentPartFieldDefinition contentPartFieldDefinition, UpdatePartFieldEditorContext context) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return null; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs index f9b07c864ef..7b802569af1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs @@ -23,7 +23,7 @@ public ContentTypePartIndexSettingsDisplayDriver(IAuthorizationService authoriza public override async Task EditAsync(ContentTypePartDefinition contentTypePartDefinition, IUpdateModel updater) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return null; } @@ -36,7 +36,7 @@ public override async Task EditAsync(ContentTypePartDefinition c public override async Task UpdateAsync(ContentTypePartDefinition contentTypePartDefinition, UpdateTypePartEditorContext context) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return null; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs index 14a34941d30..57470bf31bb 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs @@ -65,7 +65,7 @@ public override IDisplayResult Edit(ElasticSettings settings) new(S["Custom Query"], ElasticSettings.CustomSearchType), ]; }).Location("Content:2#Elasticsearch;10") - .RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) + .RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) .OnGroup(SearchConstants.SearchSettingsGroupId); public override async Task UpdateAsync(ElasticSettings section, UpdateEditorContext context) @@ -80,7 +80,7 @@ public override async Task UpdateAsync(ElasticSettings section, return null; } - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) { return null; } From 57a148a39f4d67f289dbd4850a7fc1350d5614e5 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 28 May 2024 09:55:41 -0700 Subject: [PATCH 3/6] fix a missed warning --- .../OrchardCore.Users/UserRolePermissions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs index b3d9e3319c3..e60fe297400 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs @@ -49,7 +49,7 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Administrator, Permissions = [ - AssignRoleToUsers, + CommonPermissions.AssignRoleToUsers, ], }, ]; From b72bd16b19bad611fc47c25d0d5592d1b8065989 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 28 May 2024 15:36:18 -0700 Subject: [PATCH 4/6] Update permissions --- .../OrchardCore.Admin/Permissions.cs | 2 +- .../OrchardCore.Apis.GraphQL/Permissions.cs | 5 ++- .../OrchardCore.AuditTrail/Permissions.cs | 4 +-- .../Endpoints/Api/CreateEndpoint.cs | 2 +- .../Endpoints/Api/DeleteEndpoint.cs | 2 +- .../Endpoints/Api/GetEndpoint.cs | 2 +- .../OrchardCore.Contents/Permissions.cs | 33 ++++++++++--------- .../OrchardCore.Deployment/Permissions.cs | 6 ++-- .../GoogleAnalyticsPermissionsProvider.cs | 2 +- .../NotificationPermissionsProvider.cs | 2 +- .../OrchardCore.Roles/Permissions.cs | 6 ++-- .../Controllers/AdminController.cs | 20 +++++------ ...tentPartFieldIndexSettingsDisplayDriver.cs | 4 +-- ...ntentTypePartIndexSettingsDisplayDriver.cs | 4 +-- .../Drivers/ElasticSettingsDisplayDriver.cs | 4 +-- .../ElasticsearchIndexPermissionHelper.cs | 3 +- .../Permissions.cs | 10 +++--- .../OrchardCore.Users/UserRolePermissions.cs | 2 +- .../CommonPermissions.cs | 1 + 19 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs index e4bfb32c486..97c16c4828d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs @@ -7,7 +7,7 @@ namespace OrchardCore.Admin; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'AdminPermissions.AccessAdminPanel'.")] + [Obsolete("This property will be removed in a future release. Instead use 'AdminPermissions.AccessAdminPanel'.")] public static readonly Permission AccessAdminPanel = AdminPermissions.AccessAdminPanel; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs index b75c5d1d923..5b899b0720d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs @@ -7,11 +7,10 @@ namespace OrchardCore.Apis.GraphQL; public class Permissions : IPermissionProvider { - - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ExecuteGraphQLMutations'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Apis.GraphQL.CommonPermissions.ExecuteGraphQLMutations'.")] public static readonly Permission ExecuteGraphQLMutations = CommonPermissions.ExecuteGraphQLMutations; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ExecuteGraphQL'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Apis.GraphQL.CommonPermissions.ExecuteGraphQL'.")] public static readonly Permission ExecuteGraphQL = CommonPermissions.ExecuteGraphQL; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs index 15589780a13..835d75c9503 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs @@ -7,10 +7,10 @@ namespace OrchardCore.AuditTrail; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'AuditTrailPermissions.ViewAuditTrail'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.AuditTrail.AuditTrailPermissions.ViewAuditTrail'.")] public static readonly Permission ViewAuditTrail = AuditTrailPermissions.ViewAuditTrail; - [Obsolete("This property will be removed in future release. Instead use 'AuditTrailPermissions.ManageAuditTrailSettings'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.AuditTrail.AuditTrailPermissions.ManageAuditTrailSettings'.")] public static readonly Permission ManageAuditTrailSettings = AuditTrailPermissions.ManageAuditTrailSettings; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/CreateEndpoint.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/CreateEndpoint.cs index 9fe0aa09175..877441f706c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/CreateEndpoint.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/CreateEndpoint.cs @@ -41,7 +41,7 @@ private static async Task HandleAsync( HttpContext httpContext, bool draft = false) { - if (!await authorizationService.AuthorizeAsync(httpContext.User, Permissions.AccessContentApi)) + if (!await authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.AccessContentApi)) { return httpContext.ChallengeOrForbid("Api"); } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/DeleteEndpoint.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/DeleteEndpoint.cs index 6aa0a648b5d..a9cbbbdf20c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/DeleteEndpoint.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/DeleteEndpoint.cs @@ -26,7 +26,7 @@ private static async Task HandleAsync( IAuthorizationService authorizationService, HttpContext httpContext) { - if (!await authorizationService.AuthorizeAsync(httpContext.User, Permissions.AccessContentApi)) + if (!await authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.AccessContentApi)) { return httpContext.ChallengeOrForbid("Api"); } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/GetEndpoint.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/GetEndpoint.cs index faff9130759..981d1d72029 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/GetEndpoint.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/GetEndpoint.cs @@ -26,7 +26,7 @@ private static async Task HandleAsync( IAuthorizationService authorizationService, HttpContext httpContext) { - if (!await authorizationService.AuthorizeAsync(httpContext.User, Permissions.AccessContentApi)) + if (!await authorizationService.AuthorizeAsync(httpContext.User, CommonPermissions.AccessContentApi)) { return httpContext.ChallengeOrForbid("Api"); } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs index 007886866c6..eeafdc144d7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs @@ -12,48 +12,49 @@ public class Permissions : IPermissionProvider // EditOwn is the permission that is ultimately required to create new content. See how the Create() method is implemented in the AdminController. - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PublishContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PublishContent'.")] public static readonly Permission PublishContent = CommonPermissions.PublishContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PublishOwnContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PublishOwnContent'.")] public static readonly Permission PublishOwnContent = CommonPermissions.PublishOwnContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.EditContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditContent'.")] public static readonly Permission EditContent = CommonPermissions.EditContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.EditOwnContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditOwnContent'.")] public static readonly Permission EditOwnContent = CommonPermissions.EditOwnContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.DeleteContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.DeleteContent'.")] public static readonly Permission DeleteContent = CommonPermissions.DeleteContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.DeleteOwnContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.DeleteOwnContent'.")] public static readonly Permission DeleteOwnContent = CommonPermissions.DeleteOwnContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ViewContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ViewContent'.")] public static readonly Permission ViewContent = CommonPermissions.ViewContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ViewOwnContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ViewOwnContent'.")] public static readonly Permission ViewOwnContent = CommonPermissions.ViewOwnContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PreviewContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PreviewContent'.")] public static readonly Permission PreviewContent = CommonPermissions.PreviewContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.PreviewOwnContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PreviewOwnContent'.")] public static readonly Permission PreviewOwnContent = CommonPermissions.PreviewOwnContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.CloneContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.CloneContent'.")] public static readonly Permission CloneContent = CommonPermissions.CloneContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.CloneOwnContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.CloneOwnContent'.")] public static readonly Permission CloneOwnContent = CommonPermissions.CloneOwnContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ListContent'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ListContent'.")] public static readonly Permission ListContent = CommonPermissions.ListContent; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.EditContentOwner'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditContentOwner'.")] public static readonly Permission EditContentOwner = CommonPermissions.EditContentOwner; + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.AccessContentApi'.")] public static readonly Permission AccessContentApi = new("AccessContentApi", "Access content via the api"); private readonly IEnumerable _readerPermissions = @@ -75,7 +76,7 @@ public class Permissions : IPermissionProvider CommonPermissions.PreviewOwnContent, CommonPermissions.CloneContent, CommonPermissions.CloneOwnContent, - AccessContentApi, + CommonPermissions.AccessContentApi, CommonPermissions.ListContent, CommonPermissions.EditContentOwner, ]; @@ -95,7 +96,7 @@ public IEnumerable GetDefaultStereotypes() => CommonPermissions.DeleteContent, CommonPermissions.PreviewContent, CommonPermissions.CloneContent, - AccessContentApi, + CommonPermissions.AccessContentApi, CommonPermissions.ListContent, CommonPermissions.EditContentOwner, ], diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs index 376fdd2fdb9..505694e4a87 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs @@ -7,13 +7,13 @@ namespace OrchardCore.Deployment; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ManageDeploymentPlan'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.ManageDeploymentPlan'.")] public static readonly Permission ManageDeploymentPlan = CommonPermissions.ManageDeploymentPlan; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.Export'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.Export'.")] public static readonly Permission Export = CommonPermissions.Export; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.Import'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.Import'.")] public static readonly Permission Import = CommonPermissions.Import; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs index 4d752b1e83a..7494a806bf8 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs @@ -7,7 +7,7 @@ namespace OrchardCore.Google; public class GoogleAnalyticsPermissionsProvider : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'Permissions.ManageGoogleAnalytics'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Google.Permissions.ManageGoogleAnalytics'.")] public static readonly Permission ManageGoogleAnalytics = Permissions.ManageGoogleAnalytics; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs index 8671aac56b7..77056cc55fc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs @@ -7,7 +7,7 @@ namespace OrchardCore.Notifications; public class NotificationPermissionsProvider : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'NotificationPermissions.ManageNotifications'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Notifications.NotificationPermissions.ManageNotifications'.")] public static readonly Permission ManageNotifications = NotificationPermissions.ManageNotifications; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs index 34aa0a0613d..57728d936ef 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs @@ -10,13 +10,13 @@ namespace OrchardCore.Roles; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ManageRoles'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Roles.CommonPermissions.ManageRoles'.")] public static readonly Permission ManageRoles = CommonPermissions.ManageRoles; - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.AssignRoles'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Roles.CommonPermissions.AssignRoles'.")] public static readonly Permission AssignRoles = CommonPermissions.AssignRoles; - [Obsolete("This property will be removed in future release. Instead use 'StandardPermissions.SiteOwner'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Security.StandardPermissions.SiteOwner'.")] public static readonly Permission SiteOwner = StandardPermissions.SiteOwner; private readonly IRoleService _roleService; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs index 12348b8319f..28f1b3ff25c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs @@ -105,7 +105,7 @@ public AdminController( public async Task Index(ContentOptions options, PagerParameters pagerParameters) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -174,7 +174,7 @@ public async Task Edit(string indexName = null) var IsCreate = string.IsNullOrWhiteSpace(indexName); var settings = new ElasticIndexSettings(); - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -213,7 +213,7 @@ public async Task Edit(string indexName = null) [HttpPost, ActionName(nameof(Edit))] public async Task EditPost(ElasticIndexSettingsViewModel model, string[] indexedContentTypes) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -313,7 +313,7 @@ public async Task EditPost(ElasticIndexSettingsViewModel model, st [HttpPost] public async Task Reset(string id) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -339,7 +339,7 @@ public async Task Reset(string id) [HttpPost] public async Task Rebuild(string id) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -377,7 +377,7 @@ public async Task Rebuild(string id) [HttpPost] public async Task Delete(ElasticIndexSettingsViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -411,7 +411,7 @@ public async Task Delete(ElasticIndexSettingsViewModel model) [HttpPost] public async Task ForceDelete(ElasticIndexSettingsViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -449,7 +449,7 @@ public async Task Mappings(string indexName) public async Task SyncSettings() { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -476,7 +476,7 @@ public async Task Query(string indexName, string query) [HttpPost] public async Task Query(AdminQueryViewModel model) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } @@ -546,7 +546,7 @@ public async Task Query(AdminQueryViewModel model) [FormValueRequired("submit.BulkAction")] public async Task IndexPost(ContentOptions options, IEnumerable itemIds) { - if (!await _authorizationService.AuthorizeAsync(User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageElasticIndexes)) { return Forbid(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs index 568b9d40841..367bfd16664 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPartFieldIndexSettingsDisplayDriver.cs @@ -23,7 +23,7 @@ public ContentPartFieldIndexSettingsDisplayDriver(IAuthorizationService authoriz public override async Task EditAsync(ContentPartFieldDefinition contentPartFieldDefinition, IUpdateModel updater) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) { return null; } @@ -36,7 +36,7 @@ public override async Task EditAsync(ContentPartFieldDefinition public override async Task UpdateAsync(ContentPartFieldDefinition contentPartFieldDefinition, UpdatePartFieldEditorContext context) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) { return null; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs index 7b802569af1..f9b07c864ef 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentTypePartIndexSettingsDisplayDriver.cs @@ -23,7 +23,7 @@ public ContentTypePartIndexSettingsDisplayDriver(IAuthorizationService authoriza public override async Task EditAsync(ContentTypePartDefinition contentTypePartDefinition, IUpdateModel updater) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) { return null; } @@ -36,7 +36,7 @@ public override async Task EditAsync(ContentTypePartDefinition c public override async Task UpdateAsync(ContentTypePartDefinition contentTypePartDefinition, UpdateTypePartEditorContext context) { - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) { return null; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs index 57470bf31bb..14a34941d30 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ElasticSettingsDisplayDriver.cs @@ -65,7 +65,7 @@ public override IDisplayResult Edit(ElasticSettings settings) new(S["Custom Query"], ElasticSettings.CustomSearchType), ]; }).Location("Content:2#Elasticsearch;10") - .RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + .RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes)) .OnGroup(SearchConstants.SearchSettingsGroupId); public override async Task UpdateAsync(ElasticSettings section, UpdateEditorContext context) @@ -80,7 +80,7 @@ public override async Task UpdateAsync(ElasticSettings section, return null; } - if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, ElasticsearchIndexPermissionHelper.ManageElasticIndexes)) + if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageElasticIndexes)) { return null; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs index c006a987f47..4b023d090b2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs @@ -6,7 +6,8 @@ namespace OrchardCore.Search.Elasticsearch; public class ElasticsearchIndexPermissionHelper { - public static readonly Permission ManageElasticIndexes = new("ManageElasticIndexes", "Manage Elasticsearch Indexes"); + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Search.Elasticsearch.Permissions.ManageElasticIndexes'.")] + public static readonly Permission ManageElasticIndexes = Permissions.ManageElasticIndexes; private static readonly Permission _indexPermissionTemplate = new("QueryElasticsearch{0}Index", "Query Elasticsearch {0} Index", new[] { ManageElasticIndexes }); diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs index 5f4bda93ac5..d0d407ed449 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Permissions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.Search.Elasticsearch.Core.Services; @@ -8,10 +7,9 @@ namespace OrchardCore.Search.Elasticsearch; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'ElasticsearchIndexPermissionHelper.ManageElasticIndexes'.")] - public static readonly Permission ManageElasticIndexes = ElasticsearchIndexPermissionHelper.ManageElasticIndexes; + public static readonly Permission ManageElasticIndexes = new("ManageElasticIndexes", "Manage Elasticsearch Indexes"); - public static readonly Permission QueryElasticApi = new("QueryElasticsearchApi", "Query Elasticsearch Api", new[] { ElasticsearchIndexPermissionHelper.ManageElasticIndexes }); + public static readonly Permission QueryElasticApi = new("QueryElasticsearchApi", "Query Elasticsearch Api", [ManageElasticIndexes]); private readonly ElasticIndexSettingsService _elasticIndexSettingsService; @@ -24,7 +22,7 @@ public async Task> GetPermissionsAsync() { var permissions = new List() { - ElasticsearchIndexPermissionHelper.ManageElasticIndexes, + ManageElasticIndexes, QueryElasticApi, }; @@ -45,7 +43,7 @@ public IEnumerable GetDefaultStereotypes() => Name = OrchardCoreConstants.Roles.Administrator, Permissions = [ - ElasticsearchIndexPermissionHelper.ManageElasticIndexes, + ManageElasticIndexes, ], }, new PermissionStereotype diff --git a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs index e60fe297400..b2b9faf6ffa 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs @@ -9,7 +9,7 @@ namespace OrchardCore.Users; public class UserRolePermissions : IPermissionProvider { - [Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.AssignRoleToUsers'.")] + [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Users.CommonPermissions.AssignRoleToUsers'.")] public static readonly Permission AssignRoleToUsers = CommonPermissions.AssignRoleToUsers; private readonly IRoleService _roleService; diff --git a/src/OrchardCore/OrchardCore.Contents.Core/CommonPermissions.cs b/src/OrchardCore/OrchardCore.Contents.Core/CommonPermissions.cs index 9a045ab07d9..593f474597c 100644 --- a/src/OrchardCore/OrchardCore.Contents.Core/CommonPermissions.cs +++ b/src/OrchardCore/OrchardCore.Contents.Core/CommonPermissions.cs @@ -28,6 +28,7 @@ public class CommonPermissions public static readonly Permission CloneOwnContent = new("CloneOwnContent", "Clone own content", new[] { CloneContent }); public static readonly Permission ListContent = new("ListContent", "List content items"); public static readonly Permission EditContentOwner = new("EditContentOwner", "Edit the owner of a content item"); + public static readonly Permission AccessContentApi = new("AccessContentApi", "Access content via the api"); public static readonly Dictionary OwnerPermissionsByName = []; From e58540feedac96e259a101a37a3ced8bb8e64e15 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 28 May 2024 15:45:59 -0700 Subject: [PATCH 5/6] fix build --- .../OrchardCore.Search.Elasticsearch/AdminMenu.cs | 4 ++-- .../ElasticsearchIndexPermissionHelper.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs index e9ab0505f36..91f64af45b4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs @@ -24,7 +24,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Action("Index", "Admin", "OrchardCore.Search.Elasticsearch") .AddClass("elasticsearchindices") .Id("elasticsearchindices") - .Permission(ElasticsearchIndexPermissionHelper.ManageElasticIndexes) + .Permission(Permissions.ManageElasticIndexes) .LocalNav() ) ) @@ -33,7 +33,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Action("Query", "Admin", "OrchardCore.Search.Elasticsearch") .AddClass("elasticsearchquery") .Id("elasticsearchquery") - .Permission(ElasticsearchIndexPermissionHelper.ManageElasticIndexes) + .Permission(Permissions.ManageElasticIndexes) .LocalNav() ) ) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs index 4b023d090b2..6996d8457eb 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs @@ -9,7 +9,7 @@ public class ElasticsearchIndexPermissionHelper [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Search.Elasticsearch.Permissions.ManageElasticIndexes'.")] public static readonly Permission ManageElasticIndexes = Permissions.ManageElasticIndexes; - private static readonly Permission _indexPermissionTemplate = new("QueryElasticsearch{0}Index", "Query Elasticsearch {0} Index", new[] { ManageElasticIndexes }); + private static readonly Permission _indexPermissionTemplate = new("QueryElasticsearch{0}Index", "Query Elasticsearch {0} Index", [Permissions.ManageElasticIndexes]); private static readonly Dictionary _permissions = []; From fb1c5f1271bbed80b7663c3991f6c729cac49465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Wed, 29 May 2024 01:57:22 +0200 Subject: [PATCH 6/6] Removing mistaken "property" --- .../OrchardCore.Admin/Permissions.cs | 2 +- .../OrchardCore.Apis.GraphQL/Permissions.cs | 4 +-- .../OrchardCore.AuditTrail/Permissions.cs | 4 +-- .../OrchardCore.Contents/Permissions.cs | 30 +++++++++---------- .../OrchardCore.Deployment/Permissions.cs | 6 ++-- .../GoogleAnalyticsPermissionsProvider.cs | 2 +- .../NotificationPermissionsProvider.cs | 2 +- .../OrchardCore.Roles/Permissions.cs | 6 ++-- .../ElasticsearchIndexPermissionHelper.cs | 2 +- .../OrchardCore.Users/UserRolePermissions.cs | 2 +- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs index 97c16c4828d..60e014f1055 100644 --- a/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Admin/Permissions.cs @@ -7,7 +7,7 @@ namespace OrchardCore.Admin; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'AdminPermissions.AccessAdminPanel'.")] + [Obsolete("This will be removed in a future release. Instead use 'AdminPermissions.AccessAdminPanel'.")] public static readonly Permission AccessAdminPanel = AdminPermissions.AccessAdminPanel; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs index 5b899b0720d..05db7f50ab7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/Permissions.cs @@ -7,10 +7,10 @@ namespace OrchardCore.Apis.GraphQL; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Apis.GraphQL.CommonPermissions.ExecuteGraphQLMutations'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Apis.GraphQL.CommonPermissions.ExecuteGraphQLMutations'.")] public static readonly Permission ExecuteGraphQLMutations = CommonPermissions.ExecuteGraphQLMutations; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Apis.GraphQL.CommonPermissions.ExecuteGraphQL'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Apis.GraphQL.CommonPermissions.ExecuteGraphQL'.")] public static readonly Permission ExecuteGraphQL = CommonPermissions.ExecuteGraphQL; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs index 835d75c9503..d1a5eb1ec78 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Permissions.cs @@ -7,10 +7,10 @@ namespace OrchardCore.AuditTrail; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.AuditTrail.AuditTrailPermissions.ViewAuditTrail'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.AuditTrail.AuditTrailPermissions.ViewAuditTrail'.")] public static readonly Permission ViewAuditTrail = AuditTrailPermissions.ViewAuditTrail; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.AuditTrail.AuditTrailPermissions.ManageAuditTrailSettings'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.AuditTrail.AuditTrailPermissions.ManageAuditTrailSettings'.")] public static readonly Permission ManageAuditTrailSettings = AuditTrailPermissions.ManageAuditTrailSettings; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs index eeafdc144d7..909ca427d48 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Permissions.cs @@ -12,49 +12,49 @@ public class Permissions : IPermissionProvider // EditOwn is the permission that is ultimately required to create new content. See how the Create() method is implemented in the AdminController. - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PublishContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PublishContent'.")] public static readonly Permission PublishContent = CommonPermissions.PublishContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PublishOwnContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PublishOwnContent'.")] public static readonly Permission PublishOwnContent = CommonPermissions.PublishOwnContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditContent'.")] public static readonly Permission EditContent = CommonPermissions.EditContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditOwnContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditOwnContent'.")] public static readonly Permission EditOwnContent = CommonPermissions.EditOwnContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.DeleteContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.DeleteContent'.")] public static readonly Permission DeleteContent = CommonPermissions.DeleteContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.DeleteOwnContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.DeleteOwnContent'.")] public static readonly Permission DeleteOwnContent = CommonPermissions.DeleteOwnContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ViewContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ViewContent'.")] public static readonly Permission ViewContent = CommonPermissions.ViewContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ViewOwnContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ViewOwnContent'.")] public static readonly Permission ViewOwnContent = CommonPermissions.ViewOwnContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PreviewContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PreviewContent'.")] public static readonly Permission PreviewContent = CommonPermissions.PreviewContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PreviewOwnContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.PreviewOwnContent'.")] public static readonly Permission PreviewOwnContent = CommonPermissions.PreviewOwnContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.CloneContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.CloneContent'.")] public static readonly Permission CloneContent = CommonPermissions.CloneContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.CloneOwnContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.CloneOwnContent'.")] public static readonly Permission CloneOwnContent = CommonPermissions.CloneOwnContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ListContent'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.ListContent'.")] public static readonly Permission ListContent = CommonPermissions.ListContent; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditContentOwner'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.EditContentOwner'.")] public static readonly Permission EditContentOwner = CommonPermissions.EditContentOwner; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.AccessContentApi'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Contents.CommonPermissions.AccessContentApi'.")] public static readonly Permission AccessContentApi = new("AccessContentApi", "Access content via the api"); private readonly IEnumerable _readerPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs index 505694e4a87..2a239898c42 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Permissions.cs @@ -7,13 +7,13 @@ namespace OrchardCore.Deployment; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.ManageDeploymentPlan'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.ManageDeploymentPlan'.")] public static readonly Permission ManageDeploymentPlan = CommonPermissions.ManageDeploymentPlan; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.Export'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.Export'.")] public static readonly Permission Export = CommonPermissions.Export; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.Import'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Deployment.CommonPermissions.Import'.")] public static readonly Permission Import = CommonPermissions.Import; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs index 7494a806bf8..27cdbbffb30 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsPermissionsProvider.cs @@ -7,7 +7,7 @@ namespace OrchardCore.Google; public class GoogleAnalyticsPermissionsProvider : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Google.Permissions.ManageGoogleAnalytics'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Google.Permissions.ManageGoogleAnalytics'.")] public static readonly Permission ManageGoogleAnalytics = Permissions.ManageGoogleAnalytics; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs index 77056cc55fc..898440b2fbf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Notifications/NotificationPermissionsProvider.cs @@ -7,7 +7,7 @@ namespace OrchardCore.Notifications; public class NotificationPermissionsProvider : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Notifications.NotificationPermissions.ManageNotifications'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Notifications.NotificationPermissions.ManageNotifications'.")] public static readonly Permission ManageNotifications = NotificationPermissions.ManageNotifications; private readonly IEnumerable _allPermissions = diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs index 57728d936ef..eb4281ffce6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Permissions.cs @@ -10,13 +10,13 @@ namespace OrchardCore.Roles; public class Permissions : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Roles.CommonPermissions.ManageRoles'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Roles.CommonPermissions.ManageRoles'.")] public static readonly Permission ManageRoles = CommonPermissions.ManageRoles; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Roles.CommonPermissions.AssignRoles'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Roles.CommonPermissions.AssignRoles'.")] public static readonly Permission AssignRoles = CommonPermissions.AssignRoles; - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Security.StandardPermissions.SiteOwner'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Security.StandardPermissions.SiteOwner'.")] public static readonly Permission SiteOwner = StandardPermissions.SiteOwner; private readonly IRoleService _roleService; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs index 6996d8457eb..2e3ae4c46b5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs @@ -6,7 +6,7 @@ namespace OrchardCore.Search.Elasticsearch; public class ElasticsearchIndexPermissionHelper { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Search.Elasticsearch.Permissions.ManageElasticIndexes'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Search.Elasticsearch.Permissions.ManageElasticIndexes'.")] public static readonly Permission ManageElasticIndexes = Permissions.ManageElasticIndexes; private static readonly Permission _indexPermissionTemplate = new("QueryElasticsearch{0}Index", "Query Elasticsearch {0} Index", [Permissions.ManageElasticIndexes]); diff --git a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs index b2b9faf6ffa..4961d14e889 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/UserRolePermissions.cs @@ -9,7 +9,7 @@ namespace OrchardCore.Users; public class UserRolePermissions : IPermissionProvider { - [Obsolete("This property will be removed in a future release. Instead use 'OrchardCore.Users.CommonPermissions.AssignRoleToUsers'.")] + [Obsolete("This will be removed in a future release. Instead use 'OrchardCore.Users.CommonPermissions.AssignRoleToUsers'.")] public static readonly Permission AssignRoleToUsers = CommonPermissions.AssignRoleToUsers; private readonly IRoleService _roleService;