1
0
mirror of https://github.com/bitwarden/server synced 2026-01-09 20:13:24 +00:00

Merge branch 'master' into flexible-collections/deprecate-custom-collection-perm

# Conflicts:
#	src/Api/Controllers/CollectionsController.cs
#	src/Api/Utilities/ServiceCollectionExtensions.cs
#	src/Api/Vault/AuthorizationHandlers/Collections/CollectionAuthorizationHandler.cs
#	src/Api/Vault/AuthorizationHandlers/Collections/CollectionOperations.cs
#	src/Core/Context/CurrentContext.cs
#	src/Core/Services/Implementations/CollectionService.cs
#	src/Core/Services/Implementations/OrganizationService.cs
#	test/Api.Test/Controllers/CollectionsControllerTests.cs
#	test/Api.Test/Vault/AuthorizationHandlers/CollectionAuthorizationHandlerTests.cs
#	test/Core.Test/Services/CollectionServiceTests.cs
This commit is contained in:
Rui Tome
2023-11-01 12:05:19 +00:00
36 changed files with 216 additions and 206 deletions

View File

@@ -2792,15 +2792,15 @@
"commercial.core": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )"
"Core": "[2023.10.0, )"
}
},
"commercial.infrastructure.entityframework": {
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
},
"core": {
@@ -2848,7 +2848,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2856,7 +2856,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2868,7 +2868,7 @@
"migrator": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.Extensions.Logging": "[6.0.0, )",
"dbup-sqlserver": "[5.0.8, )"
}
@@ -2876,30 +2876,30 @@
"mysqlmigrations": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
},
"postgresmigrations": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
},
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
},
"sqlitemigrations": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -127,7 +127,8 @@ public class CollectionsController : Controller
}
// We always need to know which collections the current user is assigned to
var assignedOrgCollections = await _collectionRepository.GetManyByUserIdWithAccessAsync(_currentContext.UserId.Value, orgId);
var assignedOrgCollections =
await _collectionRepository.GetManyByUserIdWithAccessAsync(_currentContext.UserId.Value, orgId);
if (await _currentContext.ViewAllCollections(orgId) || await _currentContext.ManageUsers(orgId))
{
@@ -241,6 +242,7 @@ public class CollectionsController : Controller
{
// New flexible collections logic
await PutUsers_vNext(id, model);
return;
}
// Old pre-flexible collections logic follows
@@ -288,6 +290,7 @@ public class CollectionsController : Controller
{
// New flexible collections logic
await Delete_vNext(id);
return;
}
// Old pre-flexible collections logic follows
@@ -344,6 +347,7 @@ public class CollectionsController : Controller
{
// New flexible collections logic
await DeleteUser_vNext(id, orgUserId);
return;
}
// Old pre-flexible collections logic follows

View File

@@ -72,11 +72,11 @@ public class CollectionAuthorizationHandler : AuthorizationHandler<CollectionOpe
}
}
// Check if acting user is a provider user for the target organization
if (await _currentContext.ProviderUserForOrgAsync(requirement.OrganizationId))
{
context.Succeed(requirement);
}
// Check if acting user is a provider user for the target organization
if (await _currentContext.ProviderUserForOrgAsync(requirement.OrganizationId))
{
context.Succeed(requirement);
}
}
private async Task CanReadAllWithAccessAsync(AuthorizationHandlerContext context, CollectionOperationRequirement requirement,
@@ -96,11 +96,11 @@ public class CollectionAuthorizationHandler : AuthorizationHandler<CollectionOpe
}
}
// Check if acting user is a provider user for the target organization
if (await _currentContext.ProviderUserForOrgAsync(requirement.OrganizationId))
{
context.Succeed(requirement);
}
// Check if acting user is a provider user for the target organization
if (await _currentContext.ProviderUserForOrgAsync(requirement.OrganizationId))
{
context.Succeed(requirement);
}
}
}

View File

@@ -2772,15 +2772,15 @@
"commercial.core": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )"
"Core": "[2023.10.0, )"
}
},
"commercial.infrastructure.entityframework": {
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
},
"core": {
@@ -2828,7 +2828,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2836,7 +2836,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2848,9 +2848,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -2631,7 +2631,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2639,7 +2639,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2651,9 +2651,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -48,6 +48,7 @@ public static class FeatureFlagKeys
public const string FlexibleCollections = "flexible-collections";
public const string BulkCollectionAccess = "bulk-collection-access";
public const string AutofillOverlay = "autofill-overlay";
public const string ItemShare = "item-share";
public static List<string> GetAllKeys()
{

View File

@@ -2631,7 +2631,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2639,7 +2639,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2651,9 +2651,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -2631,7 +2631,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2639,7 +2639,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2651,9 +2651,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -2640,7 +2640,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2648,7 +2648,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2660,9 +2660,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -2653,7 +2653,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2661,7 +2661,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2673,9 +2673,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -2681,7 +2681,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2689,7 +2689,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
@@ -2701,9 +2701,9 @@
"sharedweb": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Infrastructure.Dapper": "[2023.9.0, )",
"Infrastructure.EntityFramework": "[2023.9.0, )"
"Core": "[2023.10.0, )",
"Infrastructure.Dapper": "[2023.10.0, )",
"Infrastructure.EntityFramework": "[2023.10.0, )"
}
}
}

View File

@@ -2631,7 +2631,7 @@
"infrastructure.dapper": {
"type": "Project",
"dependencies": {
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Dapper": "[2.0.123, )"
}
},
@@ -2639,7 +2639,7 @@
"type": "Project",
"dependencies": {
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
"Core": "[2023.9.0, )",
"Core": "[2023.10.0, )",
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",