mirror of
https://github.com/bitwarden/server
synced 2026-01-02 08:33:48 +00:00
test(auth-validator): [PM-22975] Client Version Validator - WIP changes.
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly Version MinimumClientVersion = new Version("2025.11.0");
|
||||
public static readonly Version MinimumClientVersionForV2Encryption = new Version("2025.11.0");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GetMinimumClientVersionForUserQuery(IIsV2EncryptionUserQuery isV2En
|
||||
|
||||
if (await isV2EncryptionUserQuery.Run(user))
|
||||
{
|
||||
return Constants.MinimumClientVersion;
|
||||
return Constants.MinimumClientVersionForV2Encryption;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -260,6 +260,4 @@ public class RotateUserAccountKeysCommand : IRotateUserAccountKeysCommand
|
||||
throw new InvalidOperationException("No signed security state provider for V2 user");
|
||||
}
|
||||
}
|
||||
|
||||
// Parsing moved to Bit.Core.KeyManagement.Utilities.EncryptionParsing
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ClientVersionValidator(
|
||||
IGetMinimumClientVersionForUserQuery getMinimumClientVersionForUserQuery)
|
||||
: IClientVersionValidator
|
||||
{
|
||||
private static readonly string UpgradeMessage = "Please update your app to continue using Bitwarden";
|
||||
private const string _upgradeMessage = "Please update your app to continue using Bitwarden";
|
||||
|
||||
public async Task<bool> ValidateAsync(User? user, CustomValidatorRequestContext requestContext)
|
||||
{
|
||||
@@ -25,10 +25,10 @@ public class ClientVersionValidator(
|
||||
return true;
|
||||
}
|
||||
|
||||
var clientVersion = currentContext.ClientVersion;
|
||||
var minVersion = await getMinimumClientVersionForUserQuery.Run(user);
|
||||
Version clientVersion = currentContext.ClientVersion;
|
||||
Version? minVersion = await getMinimumClientVersionForUserQuery.Run(user);
|
||||
|
||||
// Fail-open if headers are missing or no restriction
|
||||
// Allow through if headers are missing.
|
||||
if (minVersion == null)
|
||||
{
|
||||
return true;
|
||||
@@ -39,12 +39,12 @@ public class ClientVersionValidator(
|
||||
requestContext.ValidationErrorResult = new ValidationResult
|
||||
{
|
||||
Error = "invalid_client_version",
|
||||
ErrorDescription = UpgradeMessage,
|
||||
ErrorDescription = _upgradeMessage,
|
||||
IsError = true
|
||||
};
|
||||
requestContext.CustomResponse = new Dictionary<string, object>
|
||||
{
|
||||
{ "ErrorModel", new ErrorResponseModel(UpgradeMessage) }
|
||||
{ "ErrorModel", new ErrorResponseModel(_upgradeMessage) }
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user