mirror of
https://github.com/bitwarden/server
synced 2025-12-25 04:33:26 +00: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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
|
||||
@@ -84,6 +84,7 @@ public class BulkCollectionAuthorizationHandler : BulkAuthorizationHandler<Colle
|
||||
break;
|
||||
|
||||
case not null when requirement == CollectionOperations.Read:
|
||||
case not null when requirement == CollectionOperations.ReadAccess:
|
||||
await CanReadAsync(context, requirement, resources, org);
|
||||
break;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public static class CollectionOperations
|
||||
{
|
||||
public static readonly CollectionOperationRequirement Create = new() { Name = nameof(Create) };
|
||||
public static readonly CollectionOperationRequirement Read = new() { Name = nameof(Read) };
|
||||
public static readonly CollectionOperationRequirement ReadAccess = new() { Name = nameof(ReadAccess) };
|
||||
public static CollectionOperationRequirement ReadAll(Guid organizationId)
|
||||
{
|
||||
return new CollectionOperationRequirement(nameof(ReadAll), organizationId);
|
||||
|
||||
Reference in New Issue
Block a user