Skip to content

Conversation

@trmartin4
Copy link
Member

@trmartin4 trmartin4 commented Dec 29, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-27084

📔 Objective

In working on bitwarden/server#6715, the Auth team realized that we needed to use additional abstractions around the MasterPasswordUnlockData and MasterPasswordAuthenticationData when transmitting that data abstraction between client and server.

In order to avoid other teams making this mistake, I've added a sentence to both the unlock and authentication sections highlighting the need for a specific request/response model.

I also made some slight tweaks to include types in code blocks to make them stand out more in the text.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@trmartin4 trmartin4 changed the title Added callout for request/response models. Add callout for crypto request/response models Dec 29, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 29, 2025

Deploying contributing-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba91ee7
Status: ✅  Deploy successful!
Preview URL: https://590d18ff.contributing-docs.pages.dev
Branch Preview URL: https://add-crypto-response-models.contributing-docs.pages.dev

View logs

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

Logo
Checkmarx One – Scan Summary & Detailsd63ce139-8325-445c-a612-110e3505428d

Great job! No new security vulnerabilities introduced in this pull request

@trmartin4 trmartin4 added the ai-review Request a Claude code review label Dec 30, 2025
@trmartin4 trmartin4 closed this Dec 30, 2025
@trmartin4 trmartin4 reopened this Dec 30, 2025
@trmartin4 trmartin4 marked this pull request as ready for review December 30, 2025 17:47
@trmartin4 trmartin4 requested review from a team as code owners December 30, 2025 17:47
@withinfocus withinfocus added ai-review Request a Claude code review and removed ai-review Request a Claude code review labels Dec 30, 2025
In order to separate concerns between API contracts and data models, request or response models
should be used when transmitting `MasterPasswordAuthenticationData` between the server and client.
For example,
[`MasterPasswordAuthenticationDataResponseModel`](https://github.com/bitwarden/server/blob/d6528d2b89a160fd8d4a15756df6bbb4e8f58e4e/src/Api/KeyManagement/Models/Requests/MasterPasswordAuthenticationDataRequestModel.cs#L6)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ IMPORTANT: Link-text mismatch for authentication model

Details and fix

The text references MasterPasswordAuthenticationDataResponseModel but the link points to MasterPasswordAuthenticationDataRequestModel.cs in the /Requests/ directory.

Additionally, line 196 states "when the MasterPasswordAuthenticationData is sent in an API response", but Request models are typically sent in API requests, not responses.

Fix needed:

Either:

  1. Change the link to point to the actual Response model (if one exists)
  2. Change the text to say "Request" instead of "Response" and update line 196 to say "sent in an API request"

This should match the pattern used on line 164 where MasterPasswordUnlockResponseModel correctly links to a file in the /Response/ directory.

@claude
Copy link
Contributor

claude bot commented Dec 30, 2025

Claude finished @trmartin4's task in 3m 43s —— View job


Overall Assessment: APPROVE

Reviewed documentation updates to the cryptography guide. This PR successfully adds guidance on using request/response models for crypto data structures and strengthens SDK usage requirements.

Code Review Details

No issues found. The PR accomplishes its stated objectives:

  • Adds clear callouts for using MasterPasswordUnlockResponseModel and MasterPasswordAuthenticationDataRequestModel when transmitting crypto data between client and server
  • Improves consistency by formatting type names with backticks (EncString, MasterKey, etc.)
  • Strengthens SDK requirement messaging with explicit "must" language and numbered rationale
  • Adds detailed explanation of salt separation design for unlock vs authentication
  • Properly structures deprecation warning for MasterKey usage
  • Follows Docusaurus conventions and project style guide throughout

All changes are technically accurate, clearly written, and appropriately address the security concerns raised in the PR objective.

@withinfocus withinfocus added ai-review Request a Claude code review and removed ai-review Request a Claude code review labels Dec 30, 2025
@claude
Copy link
Contributor

claude bot commented Dec 31, 2025

Overall Assessment: APPROVE

Reviewed documentation updates to the cryptography guide. All changes are well-written and technically sound. The previous issue regarding link-text mismatch has been resolved.

Code Review Details

No issues found. The PR successfully:

  • Adds clear guidance on using request/response models for crypto data structures
  • Improves type name formatting with backticks throughout
  • Clarifies the salt separation design between unlock and authentication
  • Enhances documentation readability with better structure and warnings

withinfocus
withinfocus previously approved these changes Dec 31, 2025
outside of the SDK.
be written in the
[SDK](https://github.com/bitwarden/sdk-internal/tree/main/crates/bitwarden-crypto), if possible.
Existing use-cases can be continued in the TypeScript clients for now, but eventually will be
Copy link
Contributor

Choose a reason for hiding this comment

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

ℹ️ Unrelated but I don't like this language at this point because it's still suggesting not using the SDK.

Copy link
Contributor

@quexten quexten Dec 31, 2025

Choose a reason for hiding this comment

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

What exactly is the suggestion here? / What phrasing would be better?

still suggesting not using the SDK.

The phrasing clearly states that you SHOULD write SDK code, and never recommends using TS code, merely allows it for existing use-cases. All new crypto APIs are only available in the SDK, and existing crypto APIs in TypeScript are for a large part deprecated. The clarification here is that you can modify existing use-cases without having to instantly migrate them to the SDK (because doing so is not always immediately possible before a few blockers are resolved. We've seen this with the vault team).

New use-cases SHOULD be written in the SDK.

As a side note, @withinfocus / @MGibson1 if KM gets a review where people are using TS crypto APIs for a new use-case - such as DIRT adding a new type of report, or similar - is the expectation that we block the PR and request the team to re-write their changeset to work through the SDK?

Copy link
Contributor

Choose a reason for hiding this comment

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

My comment is merely because it leaves the existing use case's path open-ended, and my preference is to use stronger language about how any use case, if needing modification, really should be a shift to the SDK at that point.

I do also feel that new use cases should be SDK-only, and it's essential that's known up front before any TypeScript work is even considered. Blocking a PR is too late in the process.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair. Looking at recent PR's, I'm not sure if all teams are aware of that though.

Copy link
Member Author

Choose a reason for hiding this comment

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

How does this sound?

image

I'd like to also confirm (@quexten?) that all the TS APIs are actually deprecated in clients. That should at least give pause to any team trying to use them. I know it did for Auth. In refinement we recognized "hey, these APIs are deprecated, we better reach out to KM to understand how to do it right" when we were designing a new feature.

Existing attachments are protected using an `EncArrayBuffer`. This is just an `EncString`, but
encoded slightly differently. Again, a content-encryption-key is usually used, but not enforced.
When encrypting files for new purposes, a content-encryption-key **MUST** be used. Consider that
with the current encryption scheme, the entire file must be downloaded and loaded into ram for
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
with the current encryption scheme, the entire file must be downloaded and loaded into ram for
with the current encryption scheme, the entire file must be downloaded and loaded into memory for

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated with bd66e2e (#740)

Copy link
Contributor

@Thomas-Avery Thomas-Avery left a comment

Choose a reason for hiding this comment

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

LGTM

@trmartin4 trmartin4 merged commit 33624ab into main Jan 2, 2026
22 checks passed
@trmartin4 trmartin4 deleted the add-crypto-response-models branch January 2, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants