mirror of
https://github.com/bitwarden/server.git
synced 2025-05-12 07:02:16 -05:00
chore(feature-flag): [PM-8671] Remove new-device-verification feature flag
* Completed grouping of feature flags by team. * Completed grouping feature flags by team. * Remove email delay feature flag * Removed feature flag * Fixed reference. * Remove flag after merge. * Removed flag from server. * Removed feature flag from server * Remove new device verification feature flag. * Removed unnecessary using. * Remove feature flag from Constants
This commit is contained in:
parent
5f7e2b8a81
commit
3989e3b26b
@ -167,7 +167,6 @@ public class UsersController : Controller
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
[RequirePermission(Permission.User_NewDeviceException_Edit)]
|
[RequirePermission(Permission.User_NewDeviceException_Edit)]
|
||||||
[RequireFeature(FeatureFlagKeys.NewDeviceVerification)]
|
|
||||||
public async Task<IActionResult> ToggleNewDeviceVerification(Guid id)
|
public async Task<IActionResult> ToggleNewDeviceVerification(Guid id)
|
||||||
{
|
{
|
||||||
var user = await _userRepository.GetByIdAsync(id);
|
var user = await _userRepository.GetByIdAsync(id);
|
||||||
|
@ -693,7 +693,6 @@ public class AccountsController : Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequireFeature(FeatureFlagKeys.NewDeviceVerification)]
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost("resend-new-device-otp")]
|
[HttpPost("resend-new-device-otp")]
|
||||||
public async Task ResendNewDeviceOtpAsync([FromBody] UnauthenticatedSecretVerificationRequestModel request)
|
public async Task ResendNewDeviceOtpAsync([FromBody] UnauthenticatedSecretVerificationRequestModel request)
|
||||||
|
@ -115,7 +115,6 @@ public static class FeatureFlagKeys
|
|||||||
public const string TwoFactorExtensionDataPersistence = "pm-9115-two-factor-extension-data-persistence";
|
public const string TwoFactorExtensionDataPersistence = "pm-9115-two-factor-extension-data-persistence";
|
||||||
public const string EmailVerification = "email-verification";
|
public const string EmailVerification = "email-verification";
|
||||||
public const string UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh";
|
public const string UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh";
|
||||||
public const string NewDeviceVerification = "new-device-verification";
|
|
||||||
public const string SetInitialPasswordRefactor = "pm-16117-set-initial-password-refactor";
|
public const string SetInitialPasswordRefactor = "pm-16117-set-initial-password-refactor";
|
||||||
public const string ChangeExistingPasswordRefactor = "pm-16117-change-existing-password-refactor";
|
public const string ChangeExistingPasswordRefactor = "pm-16117-change-existing-password-refactor";
|
||||||
public const string RecoveryCodeLogin = "pm-17128-recovery-code-login";
|
public const string RecoveryCodeLogin = "pm-17128-recovery-code-login";
|
||||||
|
@ -22,8 +22,7 @@ public class DeviceValidator(
|
|||||||
ICurrentContext currentContext,
|
ICurrentContext currentContext,
|
||||||
IUserService userService,
|
IUserService userService,
|
||||||
IDistributedCache distributedCache,
|
IDistributedCache distributedCache,
|
||||||
ILogger<DeviceValidator> logger,
|
ILogger<DeviceValidator> logger) : IDeviceValidator
|
||||||
IFeatureService featureService) : IDeviceValidator
|
|
||||||
{
|
{
|
||||||
private readonly IDeviceService _deviceService = deviceService;
|
private readonly IDeviceService _deviceService = deviceService;
|
||||||
private readonly IDeviceRepository _deviceRepository = deviceRepository;
|
private readonly IDeviceRepository _deviceRepository = deviceRepository;
|
||||||
@ -33,7 +32,6 @@ public class DeviceValidator(
|
|||||||
private readonly IUserService _userService = userService;
|
private readonly IUserService _userService = userService;
|
||||||
private readonly IDistributedCache distributedCache = distributedCache;
|
private readonly IDistributedCache distributedCache = distributedCache;
|
||||||
private readonly ILogger<DeviceValidator> _logger = logger;
|
private readonly ILogger<DeviceValidator> _logger = logger;
|
||||||
private readonly IFeatureService _featureService = featureService;
|
|
||||||
|
|
||||||
public async Task<bool> ValidateRequestDeviceAsync(ValidatedTokenRequest request, CustomValidatorRequestContext context)
|
public async Task<bool> ValidateRequestDeviceAsync(ValidatedTokenRequest request, CustomValidatorRequestContext context)
|
||||||
{
|
{
|
||||||
@ -64,9 +62,7 @@ public class DeviceValidator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We have established that the device is unknown at this point; begin new device verification
|
// We have established that the device is unknown at this point; begin new device verification
|
||||||
// PM-13340: remove feature flag
|
if (request.GrantType == "password" &&
|
||||||
if (_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification) &&
|
|
||||||
request.GrantType == "password" &&
|
|
||||||
request.Raw["AuthRequest"] == null &&
|
request.Raw["AuthRequest"] == null &&
|
||||||
!context.TwoFactorRequired &&
|
!context.TwoFactorRequired &&
|
||||||
!context.SsoRequired &&
|
!context.SsoRequired &&
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Bit.Core;
|
using Bit.Core.Context;
|
||||||
using Bit.Core.Context;
|
|
||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Models.Api;
|
using Bit.Core.Models.Api;
|
||||||
@ -28,7 +27,7 @@ public class DeviceValidatorTests
|
|||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
private readonly IDistributedCache _distributedCache;
|
private readonly IDistributedCache _distributedCache;
|
||||||
private readonly Logger<DeviceValidator> _logger;
|
private readonly Logger<DeviceValidator> _logger;
|
||||||
private readonly IFeatureService _featureService;
|
|
||||||
private readonly DeviceValidator _sut;
|
private readonly DeviceValidator _sut;
|
||||||
|
|
||||||
public DeviceValidatorTests()
|
public DeviceValidatorTests()
|
||||||
@ -41,7 +40,6 @@ public class DeviceValidatorTests
|
|||||||
_userService = Substitute.For<IUserService>();
|
_userService = Substitute.For<IUserService>();
|
||||||
_distributedCache = Substitute.For<IDistributedCache>();
|
_distributedCache = Substitute.For<IDistributedCache>();
|
||||||
_logger = new Logger<DeviceValidator>(Substitute.For<ILoggerFactory>());
|
_logger = new Logger<DeviceValidator>(Substitute.For<ILoggerFactory>());
|
||||||
_featureService = Substitute.For<IFeatureService>();
|
|
||||||
_sut = new DeviceValidator(
|
_sut = new DeviceValidator(
|
||||||
_deviceService,
|
_deviceService,
|
||||||
_deviceRepository,
|
_deviceRepository,
|
||||||
@ -50,8 +48,7 @@ public class DeviceValidatorTests
|
|||||||
_currentContext,
|
_currentContext,
|
||||||
_userService,
|
_userService,
|
||||||
_distributedCache,
|
_distributedCache,
|
||||||
_logger,
|
_logger);
|
||||||
_featureService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory, BitAutoData]
|
[Theory, BitAutoData]
|
||||||
@ -312,8 +309,6 @@ public class DeviceValidatorTests
|
|||||||
AddValidDeviceToRequest(request);
|
AddValidDeviceToRequest(request);
|
||||||
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
||||||
.Returns(null as Device);
|
.Returns(null as Device);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification)
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
request.GrantType = grantType;
|
request.GrantType = grantType;
|
||||||
|
|
||||||
@ -336,8 +331,6 @@ public class DeviceValidatorTests
|
|||||||
AddValidDeviceToRequest(request);
|
AddValidDeviceToRequest(request);
|
||||||
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
||||||
.Returns(null as Device);
|
.Returns(null as Device);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification)
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
request.Raw.Add("AuthRequest", "authRequest");
|
request.Raw.Add("AuthRequest", "authRequest");
|
||||||
|
|
||||||
@ -360,8 +353,6 @@ public class DeviceValidatorTests
|
|||||||
AddValidDeviceToRequest(request);
|
AddValidDeviceToRequest(request);
|
||||||
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
||||||
.Returns(null as Device);
|
.Returns(null as Device);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification)
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
context.TwoFactorRequired = true;
|
context.TwoFactorRequired = true;
|
||||||
|
|
||||||
@ -384,8 +375,6 @@ public class DeviceValidatorTests
|
|||||||
AddValidDeviceToRequest(request);
|
AddValidDeviceToRequest(request);
|
||||||
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
_deviceRepository.GetByIdentifierAsync(context.Device.Identifier, context.User.Id)
|
||||||
.Returns(null as Device);
|
.Returns(null as Device);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification)
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
context.SsoRequired = true;
|
context.SsoRequired = true;
|
||||||
|
|
||||||
@ -404,7 +393,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
|
|
||||||
context.User = null;
|
context.User = null;
|
||||||
@ -430,7 +418,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
context.User.VerifyDevices = false;
|
context.User.VerifyDevices = false;
|
||||||
|
|
||||||
@ -454,7 +441,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
||||||
context.User.CreationDate = DateTime.UtcNow - TimeSpan.FromHours(23);
|
context.User.CreationDate = DateTime.UtcNow - TimeSpan.FromHours(23);
|
||||||
@ -479,7 +465,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
_distributedCache.GetAsync(Arg.Any<string>()).Returns([1]);
|
_distributedCache.GetAsync(Arg.Any<string>()).Returns([1]);
|
||||||
|
|
||||||
@ -503,7 +488,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
||||||
|
|
||||||
@ -535,7 +519,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
||||||
|
|
||||||
@ -564,7 +547,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
_distributedCache.GetAsync(Arg.Any<string>()).Returns([1]);
|
_distributedCache.GetAsync(Arg.Any<string>()).Returns([1]);
|
||||||
_deviceRepository.GetManyByUserIdAsync(context.User.Id).Returns([]);
|
_deviceRepository.GetManyByUserIdAsync(context.User.Id).Returns([]);
|
||||||
@ -590,7 +572,6 @@ public class DeviceValidatorTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
ArrangeForHandleNewDeviceVerificationTest(context, request);
|
||||||
_featureService.IsEnabled(FeatureFlagKeys.NewDeviceVerification).Returns(true);
|
|
||||||
_globalSettings.EnableNewDeviceVerification = true;
|
_globalSettings.EnableNewDeviceVerification = true;
|
||||||
_deviceRepository.GetManyByUserIdAsync(context.User.Id).Returns([new Device()]);
|
_deviceRepository.GetManyByUserIdAsync(context.User.Id).Returns([new Device()]);
|
||||||
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
_distributedCache.GetAsync(Arg.Any<string>()).Returns(null as byte[]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user