Skip to content
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

[PM-3797] Client changes to use new key rotation process #6881

Merged
merged 19 commits into from
Dec 22, 2023

Conversation

jlf0dev
Copy link
Member

@jlf0dev jlf0dev commented Nov 13, 2023

Type of change

- [ ] Bug fix
- [ ] New feature development
- [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

Final Client changes for Key Rotation Improvements.

  • Introduces a new KeyRotationService that is responsible for owning rotation process.
  • Moves Send re-encryption to the SendService (KeyRotationService shouldn't have knowledge about how domains are encrypted).
  • Moves EmergencyAccess re-encryption to the EmergencyAccessService.
  • Renames AccountRecoveryService to OrganizationUserResetPasswordService after feedback from Admin Console

Code changes

Auth

  • emergency-access-update.request.ts: New request model for domain updates that includes Id
  • emergency-access.service.ts: Moved EmergencyAccess re-encryption to the EmergencyAccessService. Add deprecated method for legacy key rotations if feature flag is off
  • key-rotation.service/api/spec/module: New key rotation service for owning the rotation process. Added api service, module, and spec file.
  • update-key.request.ts: Moved to Auth ownership. Also added new properties for including other domains.
  • migrate-legacy-encryption.component.ts: Use new key rotation service instead of old component specific service. Delete old service.
  • change-password.component.ts: Use new key rotation service.
  • settings.module.ts: Import key rotation module.

Admin Console

  • organization-user-reset-password.service.ts/spec: Responsible for re-encryption of reset password keys during key rotation. Added tests.
  • organization-user-reset-password-enrollment.request.ts: New request model for key rotations
  • reset-password.component.ts: Update AccountRecoveryService to OrganizationUserResetPasswordService
  • enroll-master-password-reset.component.ts: Update AccountRecoveryService to OrganizationUserResetPasswordService

Tools

  • send.service/spec.ts: Responsible only for re-encryption of sends during key rotation. Added tests.

Other

  • api.service.ts: Move postAccountKey to KeyRotationApiService
  • feature-flag.enum.ts: add new feature flag

Screenshots

Before you submit

  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team
  • Ensure that all UI additions follow WCAG AA requirements

@jlf0dev jlf0dev force-pushed the auth/pm-3797/admin-recovery-service branch from 82a5755 to 4417214 Compare November 28, 2023 17:40
@jlf0dev jlf0dev force-pushed the auth/pm-3797/key-rotation-upgrades branch from b3f4ff3 to 0664ced Compare November 28, 2023 17:40
Copy link
Member Author

jlf0dev commented Nov 28, 2023

@jlf0dev jlf0dev force-pushed the auth/pm-3797/admin-recovery-service branch 2 times, most recently from 953e7d4 to 9620161 Compare November 30, 2023 22:24
@jlf0dev jlf0dev force-pushed the auth/pm-3797/key-rotation-upgrades branch from 0664ced to 88a064c Compare November 30, 2023 22:24
@jlf0dev jlf0dev force-pushed the auth/pm-3797/admin-recovery-service branch from 9620161 to 2c4a5d6 Compare November 30, 2023 22:32
@jlf0dev jlf0dev force-pushed the auth/pm-3797/key-rotation-upgrades branch from 88a064c to b834845 Compare November 30, 2023 22:32
Base automatically changed from auth/pm-3797/admin-recovery-service to master December 1, 2023 22:21
@jlf0dev jlf0dev force-pushed the auth/pm-3797/key-rotation-upgrades branch from b834845 to 59f6a0a Compare December 12, 2023 19:45
@bitwarden-bot
Copy link

Logo
Checkmarx One – Scan Summary & Details0c2378e3-d0a1-49f6-afc1-9926975f695a

New Issues

Severity Issue Source File / Package Checkmarx Insight
LOW Use_Of_Hardcoded_Password /apps/web/src/app/admin-console/organizations/members/services/organization-user-reset-password/organization-user-reset-password.service.spec.ts: 112 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/admin-console/organizations/members/services/organization-user-reset-password/organization-user-reset-password.service.spec.ts: 112 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 180 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 169 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 161 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 156 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 148 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 180 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 169 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 161 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 156 Attack Vector
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/key-rotation/key-rotation.service.spec.ts: 148 Attack Vector

Fixed Issues

Severity Issue Source File / Package
LOW Use_Of_Hardcoded_Password /apps/web/src/app/admin-console/organizations/members/services/account-recovery/account-recovery.service.spec.ts: 112
LOW Use_Of_Hardcoded_Password /apps/web/src/app/admin-console/organizations/members/services/account-recovery/account-recovery.service.spec.ts: 112
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/migrate-encryption/migrate-legacy-encryption.service.spec.ts: 70
LOW Use_Of_Hardcoded_Password /apps/web/src/app/auth/migrate-encryption/migrate-legacy-encryption.service.spec.ts: 91

@jlf0dev jlf0dev force-pushed the auth/pm-3797/key-rotation-upgrades branch from 59f6a0a to 45985a8 Compare December 13, 2023 15:24
@jlf0dev jlf0dev force-pushed the auth/pm-3797/key-rotation-upgrades branch from 45985a8 to f7b2d82 Compare December 14, 2023 14:28
@jlf0dev jlf0dev changed the title Auth/pm 3797/key rotation upgrades [PM-3797] Client changes to use new key rotation process Dec 14, 2023
@jlf0dev jlf0dev marked this pull request as ready for review December 14, 2023 16:14
@jlf0dev jlf0dev requested review from a team as code owners December 14, 2023 16:14
ike-kottlowski
ike-kottlowski previously approved these changes Dec 15, 2023
Copy link
Contributor

@ike-kottlowski ike-kottlowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mighty improvement. Excellent work.

Copy link
Member

@audreyality audreyality left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit ⛏️ . Thank you for documenting the new function! ❤️

});

it("throws if the new user key is null", async () => {
await expect(sendService.getRotatedKeys(null)).rejects.toThrow();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ The throw should check to ensure that the message is correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

throw new Error("New user key is required for rotation.");
}

return await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Took a closer look and found one more nit:

⛏️ Could you break out the result of the promise.all(...) call into a separate variable? The combination of asynchronous code and the inlined map call will make this a little difficult to step through with a debugger.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I've definitely had frustrating debugging sessions dealing with the same thing. Updated!

- add easier debuggin
- check for specific error in tests
Copy link
Member

@audreyality audreyality left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Great work! 👍🏻

@jlf0dev jlf0dev merged commit a62f8cd into main Dec 22, 2023
74 checks passed
@jlf0dev jlf0dev deleted the auth/pm-3797/key-rotation-upgrades branch December 22, 2023 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants