Skip to content

Commit bde0aa3

Browse files
Merge branch 'main' of https://github.com/bitwarden/server into vault/pm-20041/mark-task-complete
2 parents 963c7e9 + 2e14a46 commit bde0aa3

File tree

149 files changed

+2216
-2076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+2216
-2076
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
types: [opened, synchronize]
1212
workflow_call:
1313
inputs: {}
14+
15+
permissions:
16+
contents: read
1417

1518
env:
1619
_AZ_REGISTRY: "bitwardenprod.azurecr.io"
@@ -237,18 +240,10 @@ jobs:
237240
fi
238241
echo "tags=$TAGS" >> $GITHUB_OUTPUT
239242
240-
- name: Generate image full name
241-
id: cache-name
242-
env:
243-
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
244-
run: echo "name=${_AZ_REGISTRY}/${PROJECT_NAME}:buildcache" >> $GITHUB_OUTPUT
245-
246243
- name: Build Docker image
247244
id: build-artifacts
248245
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0
249246
with:
250-
cache-from: type=registry,ref=${{ steps.cache-name.outputs.name }}
251-
cache-to: type=registry,ref=${{ steps.cache-name.outputs.name}},mode=max
252247
context: .
253248
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
254249
platforms: |
@@ -605,6 +600,7 @@ jobs:
605600
project: server
606601
pull_request_number: ${{ github.event.number }}
607602
secrets: inherit
603+
permissions: read-all
608604

609605
check-failures:
610606
name: Check for failures

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55

6-
<Version>2025.5.2</Version>
6+
<Version>2025.6.0</Version>
77

88
<RootNamespace>Bit.$(MSBuildProjectName)</RootNamespace>
99
<ImplicitUsings>enable</ImplicitUsings>
@@ -69,4 +69,4 @@
6969
</AssemblyAttribute>
7070
</ItemGroup>
7171
</Target>
72-
</Project>
72+
</Project>

bitwarden_license/src/Commercial.Core/AdminConsole/Services/ProviderService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ public async Task<List<Tuple<ProviderUser, string>>> ConfirmUsersAsync(Guid prov
287287

288288
foreach (var user in users)
289289
{
290-
if (!keyedFilteredUsers.ContainsKey(user.Id))
290+
if (!keyedFilteredUsers.TryGetValue(user.Id, out var providerUser))
291291
{
292292
continue;
293293
}
294-
var providerUser = keyedFilteredUsers[user.Id];
295294
try
296295
{
297296
if (providerUser.Status != ProviderUserStatusType.Accepted || providerUser.ProviderId != providerId)

bitwarden_license/src/Scim/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static void Main(string[] args)
1616
{
1717
var context = e.Properties["SourceContext"].ToString();
1818

19-
if (e.Properties.ContainsKey("RequestPath") &&
20-
!string.IsNullOrWhiteSpace(e.Properties["RequestPath"]?.ToString()) &&
19+
if (e.Properties.TryGetValue("RequestPath", out var requestPath) &&
20+
!string.IsNullOrWhiteSpace(requestPath?.ToString()) &&
2121
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
2222
{
2323
return false;

bitwarden_license/src/Sso/Controllers/AccountController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ public async Task<IActionResult> Logout(string logoutId)
370370
// for the user identifier.
371371
static bool nameIdIsNotTransient(Claim c) => c.Type == ClaimTypes.NameIdentifier
372372
&& (c.Properties == null
373-
|| !c.Properties.ContainsKey(SamlPropertyKeys.ClaimFormat)
374-
|| c.Properties[SamlPropertyKeys.ClaimFormat] != SamlNameIdFormats.Transient);
373+
|| !c.Properties.TryGetValue(SamlPropertyKeys.ClaimFormat, out var claimFormat)
374+
|| claimFormat != SamlNameIdFormats.Transient);
375375

376376
// Try to determine the unique id of the external user (issued by the provider)
377377
// the most common claim type for that are the sub claim and the NameIdentifier

bitwarden_license/src/Sso/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public static void Main(string[] args)
1717
logging.AddSerilog(hostingContext, (e, globalSettings) =>
1818
{
1919
var context = e.Properties["SourceContext"].ToString();
20-
if (e.Properties.ContainsKey("RequestPath") &&
21-
!string.IsNullOrWhiteSpace(e.Properties["RequestPath"]?.ToString()) &&
20+
if (e.Properties.TryGetValue("RequestPath", out var requestPath) &&
21+
!string.IsNullOrWhiteSpace(requestPath?.ToString()) &&
2222
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
2323
{
2424
return false;

bitwarden_license/src/Sso/Utilities/OpenIdConnectOptionsExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public static async Task<bool> CouldHandleAsync(this OpenIdConnectOptions option
4646

4747
// Handle State if we've gotten that back
4848
var decodedState = options.StateDataFormat.Unprotect(state);
49-
if (decodedState != null && decodedState.Items.ContainsKey("scheme"))
49+
if (decodedState != null && decodedState.Items.TryGetValue("scheme", out var stateScheme))
5050
{
51-
return decodedState.Items["scheme"] == scheme;
51+
return stateScheme == scheme;
5252
}
5353
}
5454
catch

dev/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ services:
9999
- idp
100100

101101
rabbitmq:
102-
image: rabbitmq:management
102+
image: rabbitmq:4.1.0-management
103103
container_name: rabbitmq
104104
ports:
105105
- "5672:5672"
@@ -108,7 +108,7 @@ services:
108108
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
109109
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
110110
volumes:
111-
- rabbitmq_data:/var/lib/rabbitmq_data
111+
- rabbitmq_data:/var/lib/rabbitmq
112112
profiles:
113113
- rabbitmq
114114

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
},
66
"msbuild-sdks": {
77
"Microsoft.Build.Traversal": "4.1.0",
8-
"Microsoft.Build.Sql": "0.1.9-preview"
8+
"Microsoft.Build.Sql": "1.0.0"
99
}
1010
}

src/Admin/AdminConsole/Controllers/OrganizationsController.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@
1212
using Bit.Core.Billing.Extensions;
1313
using Bit.Core.Billing.Pricing;
1414
using Bit.Core.Billing.Providers.Services;
15-
using Bit.Core.Context;
1615
using Bit.Core.Enums;
1716
using Bit.Core.Models.OrganizationConnectionConfigs;
1817
using Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.Interfaces;
1918
using Bit.Core.Repositories;
2019
using Bit.Core.SecretsManager.Repositories;
2120
using Bit.Core.Services;
2221
using Bit.Core.Settings;
23-
using Bit.Core.Tools.Enums;
24-
using Bit.Core.Tools.Models.Business;
25-
using Bit.Core.Tools.Services;
2622
using Bit.Core.Utilities;
2723
using Bit.Core.Vault.Repositories;
2824
using Microsoft.AspNetCore.Authorization;
@@ -45,12 +41,9 @@ public class OrganizationsController : Controller
4541
private readonly IPaymentService _paymentService;
4642
private readonly IApplicationCacheService _applicationCacheService;
4743
private readonly GlobalSettings _globalSettings;
48-
private readonly IReferenceEventService _referenceEventService;
49-
private readonly IUserService _userService;
5044
private readonly IProviderRepository _providerRepository;
5145
private readonly ILogger<OrganizationsController> _logger;
5246
private readonly IAccessControlService _accessControlService;
53-
private readonly ICurrentContext _currentContext;
5447
private readonly ISecretRepository _secretRepository;
5548
private readonly IProjectRepository _projectRepository;
5649
private readonly IServiceAccountRepository _serviceAccountRepository;
@@ -73,12 +66,9 @@ public OrganizationsController(
7366
IPaymentService paymentService,
7467
IApplicationCacheService applicationCacheService,
7568
GlobalSettings globalSettings,
76-
IReferenceEventService referenceEventService,
77-
IUserService userService,
7869
IProviderRepository providerRepository,
7970
ILogger<OrganizationsController> logger,
8071
IAccessControlService accessControlService,
81-
ICurrentContext currentContext,
8272
ISecretRepository secretRepository,
8373
IProjectRepository projectRepository,
8474
IServiceAccountRepository serviceAccountRepository,
@@ -100,12 +90,9 @@ public OrganizationsController(
10090
_paymentService = paymentService;
10191
_applicationCacheService = applicationCacheService;
10292
_globalSettings = globalSettings;
103-
_referenceEventService = referenceEventService;
104-
_userService = userService;
10593
_providerRepository = providerRepository;
10694
_logger = logger;
10795
_accessControlService = accessControlService;
108-
_currentContext = currentContext;
10996
_secretRepository = secretRepository;
11097
_projectRepository = projectRepository;
11198
_serviceAccountRepository = serviceAccountRepository;
@@ -272,11 +259,6 @@ await HandlePotentialProviderSeatScalingAsync(
272259
await _organizationRepository.ReplaceAsync(organization);
273260

274261
await _applicationCacheService.UpsertOrganizationAbilityAsync(organization);
275-
await _referenceEventService.RaiseEventAsync(new ReferenceEvent(ReferenceEventType.OrganizationEditedByAdmin, organization, _currentContext)
276-
{
277-
EventRaisedByUser = _userService.GetUserName(User),
278-
SalesAssistedTrialStarted = model.SalesAssistedTrialStarted,
279-
});
280262

281263
return RedirectToAction("Edit", new { id });
282264
}

src/Admin/IdentityServer/ReadOnlyEnvIdentityUserStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public override Task<IdentityUser> FindByEmailAsync(string normalizedEmail,
3939
}
4040
}
4141

42-
var userStamp = usersDict.ContainsKey(normalizedEmail) ? usersDict[normalizedEmail] : null;
42+
var userStamp = usersDict.GetValueOrDefault(normalizedEmail);
4343
if (userStamp == null)
4444
{
4545
return Task.FromResult<IdentityUser>(null);

src/Admin/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public static void Main(string[] args)
2020
logging.AddSerilog(hostingContext, (e, globalSettings) =>
2121
{
2222
var context = e.Properties["SourceContext"].ToString();
23-
if (e.Properties.ContainsKey("RequestPath") &&
24-
!string.IsNullOrWhiteSpace(e.Properties["RequestPath"]?.ToString()) &&
23+
if (e.Properties.TryGetValue("RequestPath", out var requestPath) &&
24+
!string.IsNullOrWhiteSpace(requestPath?.ToString()) &&
2525
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
2626
{
2727
return false;

src/Admin/Services/AccessControlService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public bool UserHasPermission(Permission permission)
2929
}
3030

3131
var userRole = GetUserRoleFromClaim();
32-
if (string.IsNullOrEmpty(userRole) || !RolePermissionMapping.RolePermissions.ContainsKey(userRole))
32+
if (string.IsNullOrEmpty(userRole) || !RolePermissionMapping.RolePermissions.TryGetValue(userRole, out var rolePermissions))
3333
{
3434
return false;
3535
}
3636

37-
return RolePermissionMapping.RolePermissions[userRole].Contains(permission);
37+
return rolePermissions.Contains(permission);
3838
}
3939

4040
public string GetUserRole(string userEmail)

src/Api/Auth/Models/Request/TwoFactorRequestModels.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public User ToUser(User existingUser)
2525
{
2626
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
2727
}
28-
else if (providers.ContainsKey(TwoFactorProviderType.Authenticator))
28+
else
2929
{
3030
providers.Remove(TwoFactorProviderType.Authenticator);
3131
}
@@ -62,7 +62,7 @@ public User ToUser(User existingUser)
6262
{
6363
providers = [];
6464
}
65-
else if (providers.ContainsKey(TwoFactorProviderType.Duo))
65+
else
6666
{
6767
providers.Remove(TwoFactorProviderType.Duo);
6868
}
@@ -88,7 +88,7 @@ public Organization ToOrganization(Organization existingOrg)
8888
{
8989
providers = [];
9090
}
91-
else if (providers.ContainsKey(TwoFactorProviderType.OrganizationDuo))
91+
else
9292
{
9393
providers.Remove(TwoFactorProviderType.OrganizationDuo);
9494
}
@@ -145,7 +145,7 @@ public User ToUser(User existingUser)
145145
{
146146
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
147147
}
148-
else if (providers.ContainsKey(TwoFactorProviderType.YubiKey))
148+
else
149149
{
150150
providers.Remove(TwoFactorProviderType.YubiKey);
151151
}
@@ -228,7 +228,7 @@ public User ToUser(User existingUser)
228228
{
229229
providers = new Dictionary<TwoFactorProviderType, TwoFactorProvider>();
230230
}
231-
else if (providers.ContainsKey(TwoFactorProviderType.Email))
231+
else
232232
{
233233
providers.Remove(TwoFactorProviderType.Email);
234234
}

src/Api/Auth/Models/Response/TwoFactor/TwoFactorAuthenticatorResponseModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public TwoFactorAuthenticatorResponseModel(User user)
1313
ArgumentNullException.ThrowIfNull(user);
1414

1515
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Authenticator);
16-
if (provider?.MetaData?.ContainsKey("Key") ?? false)
16+
if (provider?.MetaData?.TryGetValue("Key", out var keyValue) ?? false)
1717
{
18-
Key = (string)provider.MetaData["Key"];
18+
Key = (string)keyValue;
1919
Enabled = provider.Enabled;
2020
}
2121
else

src/Api/Auth/Models/Response/TwoFactor/TwoFactorEmailResponseModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public TwoFactorEmailResponseModel(User user)
1515
}
1616

1717
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Email);
18-
if (provider?.MetaData?.ContainsKey("Email") ?? false)
18+
if (provider?.MetaData?.TryGetValue("Email", out var email) ?? false)
1919
{
20-
Email = (string)provider.MetaData["Email"];
20+
Email = (string)email;
2121
Enabled = provider.Enabled;
2222
}
2323
else

src/Api/Auth/Models/Response/TwoFactor/TwoFactorYubiKeyResponseModel.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ public TwoFactorYubiKeyResponseModel(User user)
1919
{
2020
Enabled = provider.Enabled;
2121

22-
if (provider.MetaData.ContainsKey("Key1"))
22+
if (provider.MetaData.TryGetValue("Key1", out var key1))
2323
{
24-
Key1 = (string)provider.MetaData["Key1"];
24+
Key1 = (string)key1;
2525
}
26-
if (provider.MetaData.ContainsKey("Key2"))
26+
if (provider.MetaData.TryGetValue("Key2", out var key2))
2727
{
28-
Key2 = (string)provider.MetaData["Key2"];
28+
Key2 = (string)key2;
2929
}
30-
if (provider.MetaData.ContainsKey("Key3"))
30+
if (provider.MetaData.TryGetValue("Key3", out var key3))
3131
{
32-
Key3 = (string)provider.MetaData["Key3"];
32+
Key3 = (string)key3;
3333
}
34-
if (provider.MetaData.ContainsKey("Key4"))
34+
if (provider.MetaData.TryGetValue("Key4", out var key4))
3535
{
36-
Key4 = (string)provider.MetaData["Key4"];
36+
Key4 = (string)key4;
3737
}
38-
if (provider.MetaData.ContainsKey("Key5"))
38+
if (provider.MetaData.TryGetValue("Key5", out var key5))
3939
{
40-
Key5 = (string)provider.MetaData["Key5"];
40+
Key5 = (string)key5;
4141
}
42-
if (provider.MetaData.ContainsKey("Nfc"))
42+
if (provider.MetaData.TryGetValue("Nfc", out var nfc))
4343
{
44-
Nfc = (bool)provider.MetaData["Nfc"];
44+
Nfc = (bool)nfc;
4545
}
4646
}
4747
else

src/Api/Billing/Controllers/AccountsController.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
using Bit.Core.Auth.UserFeatures.TwoFactorAuth.Interfaces;
77
using Bit.Core.Billing.Models;
88
using Bit.Core.Billing.Services;
9-
using Bit.Core.Context;
109
using Bit.Core.Exceptions;
1110
using Bit.Core.Models.Business;
1211
using Bit.Core.Services;
1312
using Bit.Core.Settings;
14-
using Bit.Core.Tools.Enums;
15-
using Bit.Core.Tools.Models.Business;
16-
using Bit.Core.Tools.Services;
1713
using Bit.Core.Utilities;
1814
using Microsoft.AspNetCore.Authorization;
1915
using Microsoft.AspNetCore.Mvc;
@@ -161,8 +157,6 @@ public async Task PostLicenseAsync(LicenseRequestModel model)
161157
[HttpPost("cancel")]
162158
public async Task PostCancelAsync(
163159
[FromBody] SubscriptionCancellationRequestModel request,
164-
[FromServices] ICurrentContext currentContext,
165-
[FromServices] IReferenceEventService referenceEventService,
166160
[FromServices] ISubscriberService subscriberService)
167161
{
168162
var user = await userService.GetUserByPrincipalAsync(User);
@@ -175,12 +169,6 @@ public async Task PostCancelAsync(
175169
await subscriberService.CancelSubscription(user,
176170
new OffboardingSurveyResponse { UserId = user.Id, Reason = request.Reason, Feedback = request.Feedback },
177171
user.IsExpired());
178-
179-
await referenceEventService.RaiseEventAsync(new ReferenceEvent(
180-
ReferenceEventType.CancelSubscription,
181-
user,
182-
currentContext)
183-
{ EndOfPeriod = user.IsExpired() });
184172
}
185173

186174
[HttpPost("reinstate-premium")]

0 commit comments

Comments
 (0)