Skip to content

Commit 0289be6

Browse files
committed
Remove feature flag
1 parent 0f4d48e commit 0289be6

File tree

3 files changed

+6
-46
lines changed

3 files changed

+6
-46
lines changed

src/Core/Constants.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ public static class FeatureFlagKeys
158158
public const string Otp6Digits = "pm-18612-otp-6-digits";
159159
public const string PM24579_PreventSsoOnExistingNonCompliantUsers = "pm-24579-prevent-sso-on-existing-non-compliant-users";
160160
public const string DisableAlternateLoginMethods = "pm-22110-disable-alternate-login-methods";
161-
public const string PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword =
162-
"pm-23174-manage-account-recovery-permission-drives-the-need-to-set-master-password";
163161
public const string RecoveryCodeSupportForSsoRequiredUsers = "pm-21153-recovery-code-support-for-sso-required";
164162
public const string MJMLBasedEmailTemplates = "mjml-based-email-templates";
165163
public const string MjmlWelcomeEmailTemplates = "pm-21741-mjml-welcome-email";

src/Identity/IdentityServer/UserDecryptionOptionsBuilder.cs

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Bit.Core;
2-
using Bit.Core.Auth.Entities;
1+
using Bit.Core.Auth.Entities;
32
using Bit.Core.Auth.Enums;
43
using Bit.Core.Auth.Models.Api.Response;
54
using Bit.Core.Auth.Utilities;
@@ -8,7 +7,6 @@
87
using Bit.Core.Enums;
98
using Bit.Core.KeyManagement.Models.Api.Response;
109
using Bit.Core.Repositories;
11-
using Bit.Core.Services;
1210
using Bit.Core.Utilities;
1311
using Bit.Identity.Utilities;
1412

@@ -26,8 +24,6 @@ public class UserDecryptionOptionsBuilder : IUserDecryptionOptionsBuilder
2624
private readonly IDeviceRepository _deviceRepository;
2725
private readonly IOrganizationUserRepository _organizationUserRepository;
2826
private readonly ILoginApprovingClientTypes _loginApprovingClientTypes;
29-
private readonly IFeatureService _featureService;
30-
3127
private UserDecryptionOptions _options = new UserDecryptionOptions();
3228
private User _user = null!;
3329
private SsoConfig? _ssoConfig;
@@ -37,15 +33,13 @@ public UserDecryptionOptionsBuilder(
3733
ICurrentContext currentContext,
3834
IDeviceRepository deviceRepository,
3935
IOrganizationUserRepository organizationUserRepository,
40-
ILoginApprovingClientTypes loginApprovingClientTypes,
41-
IFeatureService featureService
36+
ILoginApprovingClientTypes loginApprovingClientTypes
4237
)
4338
{
4439
_currentContext = currentContext;
4540
_deviceRepository = deviceRepository;
4641
_organizationUserRepository = organizationUserRepository;
4742
_loginApprovingClientTypes = loginApprovingClientTypes;
48-
_featureService = featureService;
4943
}
5044

5145
public IUserDecryptionOptionsBuilder ForUser(User user)
@@ -145,35 +139,8 @@ private async Task BuildTrustedDeviceOptionsAsync()
145139
// In the TDE flow, the users will have been JIT-provisioned at SSO callback time, and the relationship between
146140
// user and organization user will have been codified.
147141
var organizationUser = await _organizationUserRepository.GetByOrganizationAsync(_ssoConfig.OrganizationId, _user.Id);
148-
var hasManageResetPasswordPermission = false;
149-
if (_featureService.IsEnabled(FeatureFlagKeys.PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword))
150-
{
151-
hasManageResetPasswordPermission = await EvaluateHasManageResetPasswordPermission();
152-
}
153-
else
154-
{
155-
// TODO: PM-26065 remove use of above feature flag from the server, and remove this branching logic, which
156-
// has been replaced by EvaluateHasManageResetPasswordPermission.
157-
// Determine if user has manage reset password permission as post sso logic requires it for forcing users with this permission to set a MP.
158-
// When removing feature flags, please also see notes and removals intended for test suite in
159-
// Build_WhenManageResetPasswordPermissions_ShouldReturnHasManageResetPasswordPermissionTrue.
160-
161-
// when a user is being created via JIT provisioning, they will not have any orgs so we can't assume we will have orgs here
162-
if (_currentContext.Organizations != null && _currentContext.Organizations.Any(o => o.Id == _ssoConfig.OrganizationId))
163-
{
164-
// TDE requires single org so grabbing first org & id is fine.
165-
hasManageResetPasswordPermission = await _currentContext.ManageResetPassword(_ssoConfig!.OrganizationId);
166-
}
167-
168-
// If sso configuration data is not null then I know for sure that ssoConfiguration isn't null
169-
170-
// NOTE: Commented from original impl because the organization user repository call has been hoisted to support
171-
// branching paths through flagging.
172-
//organizationUser = await _organizationUserRepository.GetByOrganizationAsync(_ssoConfig.OrganizationId, _user.Id);
173-
174-
hasManageResetPasswordPermission |= organizationUser != null && (organizationUser.Type == OrganizationUserType.Owner || organizationUser.Type == OrganizationUserType.Admin);
175-
}
176-
142+
var hasManageResetPasswordPermission = await EvaluateHasManageResetPasswordPermission();
143+
177144
// They are only able to be approved by an admin if they have enrolled is reset password
178145
var hasAdminApproval = organizationUser != null && !string.IsNullOrEmpty(organizationUser.ResetPasswordKey);
179146

test/Identity.Test/IdentityServer/UserDecryptionOptionsBuilderTests.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Bit.Core;
2-
using Bit.Core.Auth.Entities;
1+
using Bit.Core.Auth.Entities;
32
using Bit.Core.Auth.Enums;
43
using Bit.Core.Auth.Models.Data;
54
using Bit.Core.Context;
@@ -25,16 +24,14 @@ public class UserDecryptionOptionsBuilderTests
2524
private readonly IOrganizationUserRepository _organizationUserRepository;
2625
private readonly ILoginApprovingClientTypes _loginApprovingClientTypes;
2726
private readonly UserDecryptionOptionsBuilder _builder;
28-
private readonly IFeatureService _featureService;
2927

3028
public UserDecryptionOptionsBuilderTests()
3129
{
3230
_currentContext = Substitute.For<ICurrentContext>();
3331
_deviceRepository = Substitute.For<IDeviceRepository>();
3432
_organizationUserRepository = Substitute.For<IOrganizationUserRepository>();
3533
_loginApprovingClientTypes = Substitute.For<ILoginApprovingClientTypes>();
36-
_featureService = Substitute.For<IFeatureService>();
37-
_builder = new UserDecryptionOptionsBuilder(_currentContext, _deviceRepository, _organizationUserRepository, _loginApprovingClientTypes, _featureService);
34+
_builder = new UserDecryptionOptionsBuilder(_currentContext, _deviceRepository, _organizationUserRepository, _loginApprovingClientTypes);
3835
var user = new User();
3936
_builder.ForUser(user);
4037
}
@@ -274,8 +271,6 @@ public async Task Build_WhenManageResetPasswordPermissions_ShouldFetchUserFromRe
274271
[OrganizationUserWithDefaultPermissions] OrganizationUser organizationUser,
275272
User user)
276273
{
277-
_featureService.IsEnabled(FeatureFlagKeys.PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword)
278-
.Returns(true);
279274
configurationData.MemberDecryptionType = MemberDecryptionType.TrustedDeviceEncryption;
280275
ssoConfig.Data = configurationData.Serialize();
281276
ssoConfig.OrganizationId = organization.Id;

0 commit comments

Comments
 (0)