adds security to changing premissions in the content dialog

This commit is contained in:
Shannon
2017-06-30 14:42:08 +10:00
parent 72bdc0f070
commit a072d4edb3
2 changed files with 9 additions and 3 deletions

View File

@@ -81,13 +81,17 @@ namespace Umbraco.Web.Editors
{
var foundContent = Services.ContentService.GetByIds(ids);
return foundContent.Select(Mapper.Map<IContent, ContentItemDisplay>);
}
}
/// <summary>
/// Updates the permissions for a content item for a particular user group
/// </summary>
/// <param name="saveModel"></param>
/// <returns></returns>
/// <remarks>
/// Permission check is done for letter 'R' which is for <see cref="ActionRights"/> which the user must have access to to update
/// </remarks>
[EnsureUserPermissionForContent("saveModel.ContentId", 'R')]
public IEnumerable<AssignedUserGroupPermissions> PostSaveUserGroupPermissions(UserGroupPermissionsSave saveModel)
{
if (saveModel.ContentId <= 0) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));

View File

@@ -42,10 +42,12 @@ namespace Umbraco.Web.WebApi.Filters
public EnsureUserPermissionForContentAttribute(string paramName)
{
Mandate.ParameterNotNullOrEmpty(paramName, "paramName");
if (string.IsNullOrWhiteSpace(paramName)) throw new ArgumentException("Value cannot be null or whitespace.", "paramName");
_paramName = paramName;
_permissionToCheck = ActionBrowse.Instance.Letter;
}
}
public EnsureUserPermissionForContentAttribute(string paramName, char permissionToCheck)
: this(paramName)
{