mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[AC-1139] Created new CollectionOperation ReadAccess and changed GetUsers_vNext to use it
This commit is contained in:
@ -566,7 +566,7 @@ public class CollectionsController : Controller
|
|||||||
private async Task<IEnumerable<SelectionReadOnlyResponseModel>> GetUsers_vNext(Guid id)
|
private async Task<IEnumerable<SelectionReadOnlyResponseModel>> GetUsers_vNext(Guid id)
|
||||||
{
|
{
|
||||||
var collection = await _collectionRepository.GetByIdAsync(id);
|
var collection = await _collectionRepository.GetByIdAsync(id);
|
||||||
var authorized = (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Read)).Succeeded;
|
var authorized = (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.ReadAccess)).Succeeded;
|
||||||
if (!authorized)
|
if (!authorized)
|
||||||
{
|
{
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
|
@ -84,6 +84,7 @@ public class BulkCollectionAuthorizationHandler : BulkAuthorizationHandler<Colle
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case not null when requirement == CollectionOperations.Read:
|
case not null when requirement == CollectionOperations.Read:
|
||||||
|
case not null when requirement == CollectionOperations.ReadAccess:
|
||||||
await CanReadAsync(context, requirement, resources, org);
|
await CanReadAsync(context, requirement, resources, org);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ public static class CollectionOperations
|
|||||||
{
|
{
|
||||||
public static readonly CollectionOperationRequirement Create = new() { Name = nameof(Create) };
|
public static readonly CollectionOperationRequirement Create = new() { Name = nameof(Create) };
|
||||||
public static readonly CollectionOperationRequirement Read = new() { Name = nameof(Read) };
|
public static readonly CollectionOperationRequirement Read = new() { Name = nameof(Read) };
|
||||||
|
public static readonly CollectionOperationRequirement ReadAccess = new() { Name = nameof(ReadAccess) };
|
||||||
public static CollectionOperationRequirement ReadAll(Guid organizationId)
|
public static CollectionOperationRequirement ReadAll(Guid organizationId)
|
||||||
{
|
{
|
||||||
return new CollectionOperationRequirement(nameof(ReadAll), organizationId);
|
return new CollectionOperationRequirement(nameof(ReadAll), organizationId);
|
||||||
|
Reference in New Issue
Block a user