2020-12-06 09:13:29 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2020-11-23 22:43:41 +11:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Web.BackOffice.Authorization
|
2020-11-23 22:43:41 +11:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-11-24 00:42:52 +11:00
|
|
|
/// An authorization requirement for <see cref="ContentPermissionsQueryStringHandler"/>
|
2020-11-23 22:43:41 +11:00
|
|
|
/// </summary>
|
|
|
|
|
public class ContentPermissionsQueryStringRequirement : IAuthorizationRequirement
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-12-06 09:13:29 +01:00
|
|
|
/// Initializes a new instance of the <see cref="ContentPermissionsQueryStringRequirement"/> class for a specific node id.
|
2020-11-23 22:43:41 +11:00
|
|
|
/// </summary>
|
2020-12-06 09:13:29 +01:00
|
|
|
/// <param name="nodeId">The node Id.</param>
|
|
|
|
|
/// <param name="permissionToCheck">The permission to authorize the current user against.</param>
|
2020-11-23 22:43:41 +11:00
|
|
|
public ContentPermissionsQueryStringRequirement(int nodeId, char permissionToCheck)
|
|
|
|
|
{
|
|
|
|
|
NodeId = nodeId;
|
|
|
|
|
PermissionToCheck = permissionToCheck;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-12-06 09:13:29 +01:00
|
|
|
/// Initializes a new instance of the <see cref="ContentPermissionsQueryStringRequirement"/> class for a
|
|
|
|
|
/// node id based on a query string parameter.
|
2020-11-23 22:43:41 +11:00
|
|
|
/// </summary>
|
2020-12-06 09:13:29 +01:00
|
|
|
/// <param name="paramName">The querystring parameter name.</param>
|
|
|
|
|
/// <param name="permissionToCheck">The permission to authorize the current user against.</param>
|
2020-11-24 11:56:53 +11:00
|
|
|
public ContentPermissionsQueryStringRequirement(char permissionToCheck, string paramName = "id")
|
2020-11-23 22:43:41 +11:00
|
|
|
{
|
2020-11-24 11:56:53 +11:00
|
|
|
QueryStringName = paramName;
|
2020-11-23 22:43:41 +11:00
|
|
|
PermissionToCheck = permissionToCheck;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-06 09:13:29 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specific node Id.
|
|
|
|
|
/// </summary>
|
2020-11-23 22:43:41 +11:00
|
|
|
public int? NodeId { get; }
|
2020-12-06 09:13:29 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the querystring parameter name.
|
|
|
|
|
/// </summary>
|
2020-11-24 11:56:53 +11:00
|
|
|
public string QueryStringName { get; }
|
2020-12-06 09:13:29 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the permission to authorize the current user against.
|
|
|
|
|
/// </summary>
|
2020-11-23 22:43:41 +11:00
|
|
|
public char PermissionToCheck { get; }
|
|
|
|
|
}
|
|
|
|
|
}
|