Skip to content

Commit cdd4d2a

Browse files
Zeegaanbergmania
andauthored
Merge pull request from GHSA-cfr5-7p54-4qg8
* Bump version * Apply authorization policies to controllers * Return bad request if we urltracking is disabled * Apply authorization policies to controllers * Return bad request if we urltracking is disabled --------- Co-authored-by: Bjarke Berg <[email protected]> Co-authored-by: Zeegaan <[email protected]>
1 parent be5a740 commit cdd4d2a

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

src/Umbraco.Web.BackOffice/Controllers/AnalyticsController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
using Microsoft.AspNetCore.Authorization;
12
using Microsoft.AspNetCore.Mvc;
23
using Umbraco.Cms.Core.Models;
34
using Umbraco.Cms.Core.Services;
5+
using Umbraco.Cms.Web.Common.Authorization;
46

57
namespace Umbraco.Cms.Web.BackOffice.Controllers;
68

9+
[Authorize(Policy = AuthorizationPolicies.SectionAccessSettings)]
710
public class AnalyticsController : UmbracoAuthorizedJsonController
811
{
912
private readonly IMetricsConsentService _metricsConsentService;

src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers;
1818
/// Backoffice controller supporting the dashboard for language administration.
1919
/// </summary>
2020
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
21+
[Authorize(Policy = AuthorizationPolicies.SectionAccessSettings)]
2122
public class LanguageController : UmbracoAuthorizedJsonController
2223
{
2324
private readonly ILocalizationService _localizationService;

src/Umbraco.Web.BackOffice/Controllers/PublishedSnapshotCacheStatusController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
using Microsoft.AspNetCore.Authorization;
12
using Microsoft.AspNetCore.Mvc;
23
using Umbraco.Cms.Core;
34
using Umbraco.Cms.Core.Cache;
45
using Umbraco.Cms.Core.PublishedCache;
56
using Umbraco.Cms.Web.Common.Attributes;
7+
using Umbraco.Cms.Web.Common.Authorization;
68
using Umbraco.Extensions;
79

810
namespace Umbraco.Cms.Web.BackOffice.Controllers;
911

1012
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
13+
[Authorize(Policy = AuthorizationPolicies.SectionAccessSettings)]
1114
public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController
1215
{
1316
private readonly DistributedCache _distributedCache;

src/Umbraco.Web.BackOffice/Controllers/RedirectUrlManagementController.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See LICENSE for more details.
33

44
using System.Security;
5+
using Microsoft.AspNetCore.Authorization;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.Extensions.Logging;
78
using Microsoft.Extensions.Options;
@@ -14,11 +15,13 @@
1415
using Umbraco.Cms.Core.Security;
1516
using Umbraco.Cms.Core.Services;
1617
using Umbraco.Cms.Web.Common.Attributes;
18+
using Umbraco.Cms.Web.Common.Authorization;
1719
using Umbraco.Extensions;
1820

1921
namespace Umbraco.Cms.Web.BackOffice.Controllers;
2022

2123
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
24+
[Authorize(Policy = AuthorizationPolicies.SectionAccessContent)]
2225
public class RedirectUrlManagementController : UmbracoAuthorizedApiController
2326
{
2427
private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor;
@@ -45,16 +48,17 @@ public RedirectUrlManagementController(
4548
_configManipulator = configManipulator ?? throw new ArgumentNullException(nameof(configManipulator));
4649
}
4750

51+
private bool IsEnabled => _webRoutingSettings.CurrentValue.DisableRedirectUrlTracking == false;
52+
4853
/// <summary>
4954
/// Returns true/false of whether redirect tracking is enabled or not
5055
/// </summary>
5156
/// <returns></returns>
5257
[HttpGet]
5358
public IActionResult GetEnableState()
5459
{
55-
var enabled = _webRoutingSettings.CurrentValue.DisableRedirectUrlTracking == false;
5660
var userIsAdmin = _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.IsAdmin() ?? false;
57-
return Ok(new { enabled, userIsAdmin });
61+
return Ok(new { enabled = IsEnabled, userIsAdmin });
5862
}
5963

6064
//add paging
@@ -104,6 +108,11 @@ public RedirectUrlSearchResult RedirectUrlsForContentItem(string contentUdi)
104108
[HttpPost]
105109
public IActionResult DeleteRedirectUrl(Guid id)
106110
{
111+
if (IsEnabled is false)
112+
{
113+
return BadRequest("Redirect URL tracking is disabled, and therefore no URLs can be deleted.");
114+
}
115+
107116
_redirectUrlService.Delete(id);
108117
return Ok();
109118
}

src/Umbraco.Web.BackOffice/Controllers/StylesheetController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
using Microsoft.AspNetCore.Authorization;
12
using Umbraco.Cms.Core;
23
using Umbraco.Cms.Core.Models;
34
using Umbraco.Cms.Core.Models.ContentEditing;
45
using Umbraco.Cms.Core.Services;
56
using Umbraco.Cms.Web.Common.Attributes;
7+
using Umbraco.Cms.Web.Common.Authorization;
68
using Umbraco.Extensions;
79
using Stylesheet = Umbraco.Cms.Core.Models.ContentEditing.Stylesheet;
810

@@ -12,6 +14,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers;
1214
/// The API controller used for retrieving available stylesheets
1315
/// </summary>
1416
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
17+
[Authorize(Policy = AuthorizationPolicies.SectionAccessSettings)]
1518
public class StylesheetController : UmbracoAuthorizedJsonController
1619
{
1720
private readonly IFileService _fileService;

0 commit comments

Comments
 (0)