-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-28337] Remove account recovery permission feature flag #6698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
0f4d48e
0289be6
039c0ae
6b29345
649e4b9
c2f27a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,8 +158,6 @@ public static class FeatureFlagKeys | |
| public const string Otp6Digits = "pm-18612-otp-6-digits"; | ||
| public const string PM24579_PreventSsoOnExistingNonCompliantUsers = "pm-24579-prevent-sso-on-existing-non-compliant-users"; | ||
| public const string DisableAlternateLoginMethods = "pm-22110-disable-alternate-login-methods"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ Feature flag constant correctly removed. The removal is clean and doesn't affect any adjacent feature flags. |
||
| public const string PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword = | ||
| "pm-23174-manage-account-recovery-permission-drives-the-need-to-set-master-password"; | ||
| public const string RecoveryCodeSupportForSsoRequiredUsers = "pm-21153-recovery-code-support-for-sso-required"; | ||
| public const string MJMLBasedEmailTemplates = "mjml-based-email-templates"; | ||
| public const string MjmlWelcomeEmailTemplates = "pm-21741-mjml-welcome-email"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| ๏ปฟusing Bit.Core; | ||
| using Bit.Core.Auth.Entities; | ||
| ๏ปฟusing Bit.Core.Auth.Entities; | ||
| using Bit.Core.Auth.Enums; | ||
| using Bit.Core.Auth.Models.Api.Response; | ||
| using Bit.Core.Auth.Utilities; | ||
|
|
@@ -8,7 +7,6 @@ | |
| using Bit.Core.Enums; | ||
| using Bit.Core.KeyManagement.Models.Api.Response; | ||
| using Bit.Core.Repositories; | ||
| using Bit.Core.Services; | ||
| using Bit.Core.Utilities; | ||
| using Bit.Identity.Utilities; | ||
|
|
||
|
|
@@ -26,8 +24,6 @@ public class UserDecryptionOptionsBuilder : IUserDecryptionOptionsBuilder | |
| private readonly IDeviceRepository _deviceRepository; | ||
| private readonly IOrganizationUserRepository _organizationUserRepository; | ||
| private readonly ILoginApprovingClientTypes _loginApprovingClientTypes; | ||
| private readonly IFeatureService _featureService; | ||
|
|
||
| private UserDecryptionOptions _options = new UserDecryptionOptions(); | ||
| private User _user = null!; | ||
| private SsoConfig? _ssoConfig; | ||
|
|
@@ -37,15 +33,13 @@ public UserDecryptionOptionsBuilder( | |
| ICurrentContext currentContext, | ||
| IDeviceRepository deviceRepository, | ||
| IOrganizationUserRepository organizationUserRepository, | ||
| ILoginApprovingClientTypes loginApprovingClientTypes, | ||
| IFeatureService featureService | ||
| ILoginApprovingClientTypes loginApprovingClientTypes | ||
| ) | ||
| { | ||
| _currentContext = currentContext; | ||
| _deviceRepository = deviceRepository; | ||
| _organizationUserRepository = organizationUserRepository; | ||
| _loginApprovingClientTypes = loginApprovingClientTypes; | ||
| _featureService = featureService; | ||
| } | ||
|
|
||
| public IUserDecryptionOptionsBuilder ForUser(User user) | ||
|
|
@@ -145,34 +139,7 @@ private async Task BuildTrustedDeviceOptionsAsync() | |
| // In the TDE flow, the users will have been JIT-provisioned at SSO callback time, and the relationship between | ||
| // user and organization user will have been codified. | ||
| var organizationUser = await _organizationUserRepository.GetByOrganizationAsync(_ssoConfig.OrganizationId, _user.Id); | ||
| var hasManageResetPasswordPermission = false; | ||
| if (_featureService.IsEnabled(FeatureFlagKeys.PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword)) | ||
| { | ||
| hasManageResetPasswordPermission = await EvaluateHasManageResetPasswordPermission(); | ||
| } | ||
| else | ||
| { | ||
| // TODO: PM-26065 remove use of above feature flag from the server, and remove this branching logic, which | ||
| // has been replaced by EvaluateHasManageResetPasswordPermission. | ||
| // Determine if user has manage reset password permission as post sso logic requires it for forcing users with this permission to set a MP. | ||
| // When removing feature flags, please also see notes and removals intended for test suite in | ||
| // Build_WhenManageResetPasswordPermissions_ShouldReturnHasManageResetPasswordPermissionTrue. | ||
|
|
||
| // 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 | ||
| if (_currentContext.Organizations != null && _currentContext.Organizations.Any(o => o.Id == _ssoConfig.OrganizationId)) | ||
| { | ||
| // TDE requires single org so grabbing first org & id is fine. | ||
| hasManageResetPasswordPermission = await _currentContext.ManageResetPassword(_ssoConfig!.OrganizationId); | ||
| } | ||
|
|
||
| // If sso configuration data is not null then I know for sure that ssoConfiguration isn't null | ||
|
|
||
| // NOTE: Commented from original impl because the organization user repository call has been hoisted to support | ||
| // branching paths through flagging. | ||
| //organizationUser = await _organizationUserRepository.GetByOrganizationAsync(_ssoConfig.OrganizationId, _user.Id); | ||
|
|
||
| hasManageResetPasswordPermission |= organizationUser != null && (organizationUser.Type == OrganizationUserType.Owner || organizationUser.Type == OrganizationUserType.Admin); | ||
| } | ||
| var hasManageResetPasswordPermission = await EvaluateHasManageResetPasswordPermission(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good simplification! The feature flag branching logic has been correctly removed, and now the code always uses the However, there's an outdated comment at line 158 that still references "PM-23174". While it's not harmful, it would be cleaner to either:
Minor recommendation: Update or remove the PM-23174 comment at line 158.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ
Good simplification! The feature flag branching logic has been correctly removed, and now the code always uses the |
||
|
|
||
| // They are only able to be approved by an admin if they have enrolled is reset password | ||
| var hasAdminApproval = organizationUser != null && !string.IsNullOrEmpty(organizationUser.ResetPasswordKey); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| ๏ปฟusing Bit.Core; | ||
| using Bit.Core.Auth.Entities; | ||
| ๏ปฟusing Bit.Core.Auth.Entities; | ||
| using Bit.Core.Auth.Enums; | ||
| using Bit.Core.Auth.Models.Data; | ||
| using Bit.Core.Context; | ||
| using Bit.Core.Entities; | ||
| using Bit.Core.Enums; | ||
| using Bit.Core.Models.Data; | ||
| using Bit.Core.Repositories; | ||
| using Bit.Core.Services; | ||
| using Bit.Identity.IdentityServer; | ||
| using Bit.Identity.Test.AutoFixture; | ||
| using Bit.Identity.Utilities; | ||
|
|
@@ -25,16 +23,14 @@ public class UserDecryptionOptionsBuilderTests | |
| private readonly IOrganizationUserRepository _organizationUserRepository; | ||
| private readonly ILoginApprovingClientTypes _loginApprovingClientTypes; | ||
| private readonly UserDecryptionOptionsBuilder _builder; | ||
| private readonly IFeatureService _featureService; | ||
|
|
||
| public UserDecryptionOptionsBuilderTests() | ||
| { | ||
| _currentContext = Substitute.For<ICurrentContext>(); | ||
| _deviceRepository = Substitute.For<IDeviceRepository>(); | ||
| _organizationUserRepository = Substitute.For<IOrganizationUserRepository>(); | ||
| _loginApprovingClientTypes = Substitute.For<ILoginApprovingClientTypes>(); | ||
| _featureService = Substitute.For<IFeatureService>(); | ||
| _builder = new UserDecryptionOptionsBuilder(_currentContext, _deviceRepository, _organizationUserRepository, _loginApprovingClientTypes, _featureService); | ||
| _builder = new UserDecryptionOptionsBuilder(_currentContext, _deviceRepository, _organizationUserRepository, _loginApprovingClientTypes); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good cleanup! The However, there's an outdated comment at lines 226-230 (not part of this diff) that still references this feature flag and states "When removing the server flag, please also remove this test, and remove the FeatureService dependency from this suite and the following test." The FeatureService dependency has been removed, but the comment remains and is now misleading. The test Recommendation: In a follow-up commit, remove the outdated comment block at lines 226-230 of this file.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ
Good cleanup! The |
||
| var user = new User(); | ||
| _builder.ForUser(user); | ||
| } | ||
|
|
@@ -274,8 +270,6 @@ public async Task Build_WhenManageResetPasswordPermissions_ShouldFetchUserFromRe | |
| [OrganizationUserWithDefaultPermissions] OrganizationUser organizationUser, | ||
| User user) | ||
| { | ||
| _featureService.IsEnabled(FeatureFlagKeys.PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword) | ||
| .Returns(true); | ||
| configurationData.MemberDecryptionType = MemberDecryptionType.TrustedDeviceEncryption; | ||
| ssoConfig.Data = configurationData.Serialize(); | ||
| ssoConfig.OrganizationId = organization.Id; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
โ Feature flag constant correctly removed. The removal is clean and doesn't affect any adjacent feature flags.