1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-24 22:11:24 +01:00

[PM-14378] Introduce SecurityTaskOperationRequirement

This commit is contained in:
Shane Melton 2024-12-05 17:01:03 -08:00
parent a03ddee961
commit 532dd076fa
No known key found for this signature in database

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Authorization.Infrastructure;
namespace Bit.Core.Vault.Authorization.SecurityTasks;
public class SecurityTaskOperationRequirement : OperationAuthorizationRequirement
{
public SecurityTaskOperationRequirement(string name)
{
Name = name;
}
}
public static class SecurityTaskOperations
{
public static readonly SecurityTaskOperationRequirement Read = new SecurityTaskOperationRequirement(nameof(Read));
public static readonly SecurityTaskOperationRequirement Create = new SecurityTaskOperationRequirement(nameof(Create));
public static readonly SecurityTaskOperationRequirement Update = new SecurityTaskOperationRequirement(nameof(Update));
/// <summary>
/// List all security tasks for a specific organization.
/// <example><code>
/// var orgContext = _currentContext.GetOrganization(organizationId);
/// _authorizationService.AuthorizeOrThrowAsync(User, SecurityTaskOperations.ListAllForOrganization, orgContext);
/// </code></example>
/// </summary>
public static readonly SecurityTaskOperationRequirement ListAllForOrganization = new SecurityTaskOperationRequirement(nameof(ListAllForOrganization));
}