1
0
mirror of https://github.com/bitwarden/server synced 2026-01-08 19:43:34 +00:00

fix(auth-validator): [PM-22975] Client Version Validator - Took in team feedback.

This commit is contained in:
Patrick Pimentel
2025-12-03 14:44:33 -05:00
parent 544965e0bd
commit f719763a85
3 changed files with 18 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ using Bit.Core.Auth.Enums;
using Bit.Core.Auth.Models;
using Bit.Core.Enums;
using Bit.Core.KeyManagement.Models.Data;
using Bit.Core.KeyManagement.Utilities;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Identity;
@@ -211,7 +212,17 @@ public class User : ITableObject<Guid>, IStorableSubscriber, IRevisable, ITwoFac
return SecurityVersion ?? 1;
}
public bool IsSecurityVersionTwo()
public bool IsSetupForV2Encryption()
{
return HasV2KeyShape() && IsSecurityVersionTwo();
}
private bool HasV2KeyShape()
{
return EncryptionParsing.GetEncryptionType(PrivateKey) == EncryptionType.XChaCha20Poly1305_B64;
}
private bool IsSecurityVersionTwo()
{
return SecurityVersion == 2;
}

View File

@@ -13,7 +13,7 @@ public class GetMinimumClientVersionForUserQuery()
return Task.FromResult<Version?>(null);
}
if (user.IsSecurityVersionTwo())
if (user.IsSetupForV2Encryption())
{
return Task.FromResult(Constants.MinimumClientVersionForV2Encryption)!;
}